@extend-ai/react-xlsx 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +28 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +28 -9
- package/dist/index.js.map +1 -1
- package/dist/xlsx-worker.js +11 -3
- package/dist/xlsx-worker.js.map +1 -1
- package/package.json +1 -1
package/dist/xlsx-worker.js
CHANGED
|
@@ -4284,6 +4284,12 @@ var DEFAULT_COL_WIDTH = 80;
|
|
|
4284
4284
|
var DEFAULT_ZOOM_SCALE = 100;
|
|
4285
4285
|
var FORMULA_COUNT_THRESHOLD = 1e3;
|
|
4286
4286
|
var FAST_STRUCTURE_PARSE_THRESHOLD_BYTES = 5 * 1024 * 1024;
|
|
4287
|
+
function isLegacyXlsWorkbook(bytes) {
|
|
4288
|
+
return bytes.byteLength >= 8 && bytes[0] === 208 && bytes[1] === 207 && bytes[2] === 17 && bytes[3] === 224 && bytes[4] === 161 && bytes[5] === 177 && bytes[6] === 26 && bytes[7] === 225;
|
|
4289
|
+
}
|
|
4290
|
+
function shouldSkipXmlParsingForWorkbook(bytes, skipXmlParsing = false) {
|
|
4291
|
+
return skipXmlParsing || isLegacyXlsWorkbook(bytes);
|
|
4292
|
+
}
|
|
4287
4293
|
var workbook = null;
|
|
4288
4294
|
var chartsByWorkbookSheetIndex = [];
|
|
4289
4295
|
var chartsheets = [];
|
|
@@ -4563,6 +4569,7 @@ function cellAddressToA1(cell) {
|
|
|
4563
4569
|
async function loadWorkbook(buffer, skipXmlParsing = false) {
|
|
4564
4570
|
const wasmModule = await getSheetsWasmModule();
|
|
4565
4571
|
const bytes = new Uint8Array(buffer);
|
|
4572
|
+
const effectiveSkipXmlParsing = shouldSkipXmlParsingForWorkbook(bytes, skipXmlParsing);
|
|
4566
4573
|
const nextWorkbook = wasmModule.Workbook.fromBytes(bytes);
|
|
4567
4574
|
let totalFormulas = 0;
|
|
4568
4575
|
for (let index = 0; index < nextWorkbook.sheetCount; index += 1) {
|
|
@@ -4572,7 +4579,7 @@ async function loadWorkbook(buffer, skipXmlParsing = false) {
|
|
|
4572
4579
|
nextWorkbook.calculate();
|
|
4573
4580
|
}
|
|
4574
4581
|
const shouldUseFastStructureParse = bytes.byteLength >= FAST_STRUCTURE_PARSE_THRESHOLD_BYTES && totalFormulas <= FORMULA_COUNT_THRESHOLD;
|
|
4575
|
-
const structureAssets =
|
|
4582
|
+
const structureAssets = effectiveSkipXmlParsing || shouldUseFastStructureParse ? null : parseWorkbookStructureAssets(bytes, {
|
|
4576
4583
|
includeCachedFormulaValues: true
|
|
4577
4584
|
});
|
|
4578
4585
|
workbook = nextWorkbook;
|
|
@@ -4591,7 +4598,7 @@ async function loadWorkbook(buffer, skipXmlParsing = false) {
|
|
|
4591
4598
|
const hasModernCharts = Array.isArray(worksheet.chartsEx) && worksheet.chartsEx.length > 0;
|
|
4592
4599
|
return hasClassicCharts || hasModernCharts;
|
|
4593
4600
|
}).some(Boolean);
|
|
4594
|
-
const chartStyleAssets =
|
|
4601
|
+
const chartStyleAssets = effectiveSkipXmlParsing || !hasCharts ? null : parseWorkbookChartStyleAssets(bytes);
|
|
4595
4602
|
const chartAssets = loadWorkbookChartAssets(nextWorkbook, chartStyleAssets, visibleSheetIndexByWorkbookSheetIndex);
|
|
4596
4603
|
chartsByWorkbookSheetIndex = chartAssets.chartsByWorkbookSheetIndex;
|
|
4597
4604
|
chartsheets = chartAssets.chartsheets;
|
|
@@ -4607,6 +4614,7 @@ async function loadWorkbook(buffer, skipXmlParsing = false) {
|
|
|
4607
4614
|
async function parseCharts(buffer, skipXmlParsing = false) {
|
|
4608
4615
|
const wasmModule = await getSheetsWasmModule();
|
|
4609
4616
|
const bytes = new Uint8Array(buffer);
|
|
4617
|
+
const effectiveSkipXmlParsing = shouldSkipXmlParsingForWorkbook(bytes, skipXmlParsing);
|
|
4610
4618
|
const nextWorkbook = wasmModule.Workbook.fromBytes(bytes);
|
|
4611
4619
|
let totalFormulas = 0;
|
|
4612
4620
|
for (let index = 0; index < nextWorkbook.sheetCount; index += 1) {
|
|
@@ -4616,7 +4624,7 @@ async function parseCharts(buffer, skipXmlParsing = false) {
|
|
|
4616
4624
|
nextWorkbook.calculate();
|
|
4617
4625
|
}
|
|
4618
4626
|
const visibleSheetIndexByWorkbookSheetIndex = buildVisibleSheetIndexByWorkbookSheetIndex(nextWorkbook);
|
|
4619
|
-
const chartStyleAssets =
|
|
4627
|
+
const chartStyleAssets = effectiveSkipXmlParsing ? null : parseWorkbookChartStyleAssets(bytes);
|
|
4620
4628
|
const chartAssets = loadWorkbookChartAssets(nextWorkbook, chartStyleAssets, visibleSheetIndexByWorkbookSheetIndex);
|
|
4621
4629
|
return {
|
|
4622
4630
|
chartsByWorkbookSheetIndex: chartAssets.chartsByWorkbookSheetIndex,
|