@a3s-lab/office 0.24.0 → 0.26.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/README.md +3 -1
- package/dist/0~spreadsheet-editor.js +20305 -19251
- package/dist/0~work-office-diagnostics.js +2 -2
- package/dist/{5045.js → 164.js} +1135 -18
- package/dist/4104.js +46 -748
- package/dist/6282.js +221 -235
- package/dist/9424.js +16 -0
- package/dist/core.js +1 -1
- package/dist/index.js +1 -1
- package/dist/internal/features/work/editors/spreadsheet-command-controller.d.ts +18 -9
- package/dist/internal/features/work/editors/spreadsheet-operation-projection.d.ts +6 -0
- package/dist/internal/features/work/editors/spreadsheet-rich-text-dom-selection.d.ts +11 -0
- package/dist/internal/features/work/editors/spreadsheet-rich-text-paste.d.ts +22 -0
- package/dist/internal/features/work/editors/spreadsheet-rich-text-selection-controller.d.ts +38 -0
- package/dist/internal/features/work/editors/spreadsheet-rich-text-selection-format.d.ts +26 -0
- package/dist/internal/features/work/work-css-color.d.ts +1 -0
- package/dist/internal/features/work/work-document-paragraph-shading.d.ts +1 -1
- package/dist/internal/features/work/work-xlsx-cell-style-origin.d.ts +1 -0
- package/dist/internal/features/work/work-xlsx-colors.d.ts +1 -1
- package/dist/internal/features/work/work-xlsx-interop.d.ts +2 -0
- package/dist/internal/features/work/work-xlsx-rich-text-edit.d.ts +28 -0
- package/dist/internal/features/work/work-xlsx-rich-text-model.d.ts +40 -0
- package/dist/internal/features/work/work-xlsx-rich-text.d.ts +41 -0
- package/dist/internal/features/work/work-xlsx-worksheet-scan.d.ts +1 -0
- package/dist/internal/features/work/work-xlsx-worksheet.d.ts +5 -0
- package/dist/office-kernel.wasm +0 -0
- package/dist/work-spreadsheet-package-scan.worker.js +6 -2
- package/docs/latest/en/browser-editor-architecture.md +27 -0
- package/package.json +4 -1
package/dist/4104.js
CHANGED
|
@@ -5,7 +5,7 @@ import { OFFICE_COLLABORATION_PROTOCOL as WORK_OFFICE_COLLABORATION_PROTOCOL, Of
|
|
|
5
5
|
import { contentTypeForPart, directChildren, bytesToDataUrl, OoxmlPackage as work_ooxml_package_OoxmlPackage, parseXml, firstDescendant, xmlNamespacePrefix, descendants, directChild, createArtifact as createWorkArtifact, xmlContainsAnyElement, createOfficeId as createWorkId, attribute as work_ooxml_package_attribute } from "./5184.js";
|
|
6
6
|
import { mountWorkLiveDocumentCapture, materializeWorkDocumentContent as work_document_model_codec_materializeWorkDocumentContent, documentPageSurfaceGeometryForElement, createWorkDocumentModel, documentContentLayoutProperties, documentModelForContent, createWorkDocumentExtensions, positionWorkLiveDocumentCapture } from "./6282.js";
|
|
7
7
|
import { normalizeWorkSpreadsheetDataLabels, workSpreadsheetChartSupportsGrouping, normalizeSpreadsheetPrintArea, normalizeWorkSpreadsheetChartLegendPosition, formatSpreadsheetCellRanges, spreadsheetCellAddress, normalizeWorkSpreadsheetChartSmoothLines, spreadsheetFormulaRangeForCell, normalizeWorkSpreadsheetChartColor, readXlsxDrawingAnchor, sparseArrayEntries, qualifySpreadsheetRange, normalizeWorkSpreadsheetBubbleScale, normalizeWorkSpreadsheetChartSeriesStyle, normalizeSpreadsheetPrintTitleRows, normalizeSpreadsheetPrintTitleColumns, spreadsheetPivotFilterValueKey, normalizeWorkSpreadsheetErrorBars, normalizeWorkSpreadsheetBubbleSizeRepresents, workSpreadsheetChartSupportsTrendlines, stripSpreadsheetSheetQualifier, normalizeWorkSpreadsheetChartLegendOverlay, normalizeWorkSpreadsheetChartGapWidth, normalizeWorkSpreadsheetChartGrouping, workSpreadsheetChartSupportsBarSpacing, workSpreadsheetChartSupportsSmoothLines, workSpreadsheetChartGroupingIsStacked, xlsxDrawingAnchorToBounds, xlsxTwoCellAnchorMarkers, workSpreadsheetChartSupportsErrorBars, sparseMatrixColumnCount, refreshSpreadsheetPivotTables, normalizeWorkSpreadsheetChartAxisGroup, isValidSpreadsheetDefinedName, normalizeWorkSpreadsheetScatterStyle, workSpreadsheetChartAxisDefaultLabelPosition, spreadsheetPivotValidation, resolveSpreadsheetChart, parseSpreadsheetCellRanges, workSpreadsheetChartAxisIsCategoryAxis, spreadsheetPivotFields, normalizeWorkSpreadsheetDoughnutHoleSize, normalizeWorkSpreadsheetChartAxes, parseSpreadsheetPrintTitles, spreadsheetFormulaRangeConflict, spreadsheetFormulaForXlsx, editableSpreadsheetFormula, workSpreadsheetChartUsesNumericXAxis, normalizeWorkSpreadsheetChartOverlap, workSpreadsheetChartSupportsAxes, workSpreadsheetChartAxisShowsMajorGridlinesByDefault, normalizeWorkSpreadsheetCombinationSeriesType, effectiveSpreadsheetCalculationSettings, normalizeWorkSpreadsheetTrendline, normalizeWorkSpreadsheetRadarStyle } from "./8715.js";
|
|
8
|
-
import { freezeImportedSpreadsheetCell,
|
|
8
|
+
import { freezeImportedSpreadsheetCell, xlsxRichTextCellText, setXlsxToggleChild, work_xlsx_cell_style_values_xlsxBooleanAttribute, spreadsheetCellValueWithDiagonalBorder, xlsxColorElementMatchesOrigin, ensureXlsxStyleCollection, xlsxSemanticColorOriginKey, applyImportedXlsxRichText, hasXlsxDirectFontStyle, isSpreadsheetConditionalComparisonOperator, xlsxStyleCollectionIndex, spreadsheetExplicitTextOrientationFromCell, readXlsxSemanticColorOrigin, defaultSpreadsheetConditionalIconThresholds, DEFAULT_PROTECTION_HINT, sheetHasXlsxRichTextCells, normalizeSpreadsheetDateValidationBoundary, createXlsxColorResolver, resolveXlsxColor, setXlsxBorderLine, xlsxAlignmentMatches, xlsxBorderLineMatches, editableRangeRequiresCredentials, defaultXlsxBorder, spreadsheetDateValidationFormula, defaultSpreadsheetColorScaleThresholds, writeXlsxAlignment, spreadsheetUnderlineCellValueFromXlsx, applyXlsxSemanticColorOrigin, xlsxWorksheetCellEntries, defaultXlsxFill, spreadsheetConditionalThresholdsEqual, spreadsheetUnderlineCellValueFromSheetJs, xlsxColorMatches, withXlsxCellStyleOrigin, normalizeSpreadsheetPaperSize, normalizeSpreadsheetConditionalVisualOptions, xlsxRichTextStyleOrigins, xlsxCellStyleOrigin, directXlsxAlignment, spreadsheetTextOrientationFromXlsx, directXlsxFontStyle, registerImportedSpreadsheetMatrix, setXlsxUnderlineChild, readXlsxRichTextCells, createXlsxRichTextReadContext, setXlsxColorChild, spreadsheetTextOrientationCellStyle, normalizeSpreadsheetConditionalIconSetFormat, defaultSpreadsheetDataBarOptions, prepareXlsxSemanticPalette, normalizeSheetProtectionAuthority, importedSheetProtectionAuthority, spreadsheetDiagonalBorderFromCellValue, xlsxRgbColor, xlsxUnderlineStyle, sheetHasProtectionState, spreadsheetConditionalComparisonNeedsUpperValue, xlsxToggleEnabled, writeXlsxRichTextCells, activeXlsxSemanticColorOrigin, isSpreadsheetConditionalIconSetName, setXlsxValueChild, spreadsheetConditionalIconSetCount } from "./164.js";
|
|
9
9
|
import { WorkFileImportController, materializeWorkFileSource } from "./9356.js";
|
|
10
10
|
import "./2591.js";
|
|
11
11
|
import "./3818.js";
|
|
@@ -916,54 +916,6 @@ function encodeSpreadsheetColumn(index) {
|
|
|
916
916
|
}
|
|
917
917
|
return label;
|
|
918
918
|
}
|
|
919
|
-
function* xlsxWorksheetCellEntries(worksheet) {
|
|
920
|
-
if (Array.isArray(worksheet)) {
|
|
921
|
-
for(let row = 0; row < worksheet.length; row += 1){
|
|
922
|
-
const cells = worksheet[row];
|
|
923
|
-
if (Array.isArray(cells)) for(let column = 0; column < cells.length; column += 1){
|
|
924
|
-
const cell = cells[column];
|
|
925
|
-
if (!(!cell || 'object' != typeof cell || Array.isArray(cell))) yield {
|
|
926
|
-
address: xlsxCellAddress(row, column),
|
|
927
|
-
cell: cell,
|
|
928
|
-
column,
|
|
929
|
-
row
|
|
930
|
-
};
|
|
931
|
-
}
|
|
932
|
-
}
|
|
933
|
-
return;
|
|
934
|
-
}
|
|
935
|
-
for (const [address, cell] of Object.entries(worksheet)){
|
|
936
|
-
if (address.startsWith('!') || !cell || 'object' != typeof cell) continue;
|
|
937
|
-
const position = decodeXlsxCellAddress(address);
|
|
938
|
-
if (position) yield {
|
|
939
|
-
address,
|
|
940
|
-
cell: cell,
|
|
941
|
-
...position
|
|
942
|
-
};
|
|
943
|
-
}
|
|
944
|
-
}
|
|
945
|
-
function xlsxCellAddress(row, column) {
|
|
946
|
-
let value = column + 1;
|
|
947
|
-
let label = '';
|
|
948
|
-
while(value > 0){
|
|
949
|
-
value -= 1;
|
|
950
|
-
label = String.fromCharCode(65 + value % 26) + label;
|
|
951
|
-
value = Math.floor(value / 26);
|
|
952
|
-
}
|
|
953
|
-
return `${label}${row + 1}`;
|
|
954
|
-
}
|
|
955
|
-
function decodeXlsxCellAddress(address) {
|
|
956
|
-
const match = /^([A-Za-z]+)([1-9][0-9]*)$/.exec(address);
|
|
957
|
-
if (!match) return null;
|
|
958
|
-
let column = 0;
|
|
959
|
-
for (const character of match[1].toUpperCase())column = 26 * column + character.charCodeAt(0) - 64;
|
|
960
|
-
const row = Number(match[2]);
|
|
961
|
-
if (!Number.isSafeInteger(row) || row <= 0) return null;
|
|
962
|
-
return {
|
|
963
|
-
column: column - 1,
|
|
964
|
-
row: row - 1
|
|
965
|
-
};
|
|
966
|
-
}
|
|
967
919
|
async function readXlsxFormulaFeaturesFromPackage(archive, worksheetScans) {
|
|
968
920
|
if (!archive.has('xl/workbook.xml')) return {
|
|
969
921
|
calculation: effectiveSpreadsheetCalculationSettings(void 0),
|
|
@@ -1337,7 +1289,7 @@ function cachedText(parent) {
|
|
|
1337
1289
|
const directValue = directChild(parent, 'v')?.textContent?.trim();
|
|
1338
1290
|
return directValue || cachedValues(parent)[0] || '';
|
|
1339
1291
|
}
|
|
1340
|
-
function
|
|
1292
|
+
function work_xlsx_chart_values_richText(parent) {
|
|
1341
1293
|
return descendants(parent, 't').map((node)=>node.textContent ?? '').join('');
|
|
1342
1294
|
}
|
|
1343
1295
|
function cachedValues(parent) {
|
|
@@ -1404,7 +1356,7 @@ function parseXlsxChartAxes(document1, chartType, hasSecondaryAxes, preserveVisi
|
|
|
1404
1356
|
if ('b' !== position && 'l' !== position && 't' !== position && 'r' !== position) continue;
|
|
1405
1357
|
const key = 'b' === position ? 'bottom' : 'l' === position ? 'left' : 't' === position ? 'top' : 'right';
|
|
1406
1358
|
const title = directChild(axis, 'title');
|
|
1407
|
-
const text = title ? cachedText(title) ||
|
|
1359
|
+
const text = title ? cachedText(title) || work_xlsx_chart_values_richText(title) || void 0 : void 0;
|
|
1408
1360
|
const titleReference = title ? formulaReference(title) : void 0;
|
|
1409
1361
|
const displaySettings = parseXlsxAxisDisplaySettings(axis, chartType, key);
|
|
1410
1362
|
const valueSettings = 'valAx' === axis.localName ? parseXlsxValueAxisSettings(axis, chartType, key, preserveVisibleDefaultGridlines) : void 0;
|
|
@@ -2208,7 +2160,7 @@ function parseXlsxChart(document1) {
|
|
|
2208
2160
|
const layout = parseXlsxChartPlotLayout(chartNode, type);
|
|
2209
2161
|
return {
|
|
2210
2162
|
type,
|
|
2211
|
-
title: title ? cachedText(title) ||
|
|
2163
|
+
title: title ? cachedText(title) || work_xlsx_chart_values_richText(title) || void 0 : void 0,
|
|
2212
2164
|
titleReference: title ? formulaReference(title) : void 0,
|
|
2213
2165
|
categories: categoryNode ? cachedValues(categoryNode) : [],
|
|
2214
2166
|
categoryReference: categoryNode ? formulaReference(categoryNode) : void 0,
|
|
@@ -2256,7 +2208,7 @@ function parseXlsxCombinationChart(document1, chartNodes) {
|
|
|
2256
2208
|
const legend = parseXlsxChartLegend(document1);
|
|
2257
2209
|
return {
|
|
2258
2210
|
type: 'combination',
|
|
2259
|
-
title: title ? cachedText(title) ||
|
|
2211
|
+
title: title ? cachedText(title) || work_xlsx_chart_values_richText(title) || void 0 : void 0,
|
|
2260
2212
|
titleReference: title ? formulaReference(title) : void 0,
|
|
2261
2213
|
categories: categoryNode ? cachedValues(categoryNode) : [],
|
|
2262
2214
|
categoryReference: categoryNode ? formulaReference(categoryNode) : void 0,
|
|
@@ -2319,7 +2271,7 @@ function parseXlsxChartSeries(node, index, type, inheritedDataLabels) {
|
|
|
2319
2271
|
}) : [];
|
|
2320
2272
|
const style = parseXlsxChartSeriesStyle(node);
|
|
2321
2273
|
return {
|
|
2322
|
-
name: (title ? cachedText(title) ||
|
|
2274
|
+
name: (title ? cachedText(title) || work_xlsx_chart_values_richText(title) : '') || `Series ${index + 1}`,
|
|
2323
2275
|
nameReference: title ? formulaReference(title) : void 0,
|
|
2324
2276
|
values: values ? cachedValues(values).map((value)=>finiteNumber(value)) : [],
|
|
2325
2277
|
valuesReference: values ? formulaReference(values) : void 0,
|
|
@@ -3327,686 +3279,6 @@ function nonNegativeInteger(value) {
|
|
|
3327
3279
|
function work_xlsx_cell_borders_isRecord(value) {
|
|
3328
3280
|
return 'object' == typeof value && null !== value && !Array.isArray(value);
|
|
3329
3281
|
}
|
|
3330
|
-
const borderChildOrder = [
|
|
3331
|
-
'start',
|
|
3332
|
-
'end',
|
|
3333
|
-
'left',
|
|
3334
|
-
'right',
|
|
3335
|
-
'top',
|
|
3336
|
-
'bottom',
|
|
3337
|
-
'diagonal',
|
|
3338
|
-
'vertical',
|
|
3339
|
-
'horizontal',
|
|
3340
|
-
'extLst'
|
|
3341
|
-
];
|
|
3342
|
-
function ensureXlsxStyleCollection(document1, name, anchors) {
|
|
3343
|
-
const root = document1.documentElement;
|
|
3344
|
-
const existing = directChild(root, name);
|
|
3345
|
-
if (existing) return existing;
|
|
3346
|
-
const collection = document1.createElementNS(root.namespaceURI, name);
|
|
3347
|
-
root.insertBefore(collection, directChildren(root).find((child)=>anchors.includes(child.localName)) ?? null);
|
|
3348
|
-
return collection;
|
|
3349
|
-
}
|
|
3350
|
-
function defaultXlsxFill(document1, patternType) {
|
|
3351
|
-
const fill = document1.createElementNS(document1.documentElement.namespaceURI, 'fill');
|
|
3352
|
-
const pattern = document1.createElementNS(document1.documentElement.namespaceURI, 'patternFill');
|
|
3353
|
-
pattern.setAttribute('patternType', patternType);
|
|
3354
|
-
fill.append(pattern);
|
|
3355
|
-
return fill;
|
|
3356
|
-
}
|
|
3357
|
-
function defaultXlsxBorder(document1) {
|
|
3358
|
-
const border = document1.createElementNS(document1.documentElement.namespaceURI, 'border');
|
|
3359
|
-
for (const name of [
|
|
3360
|
-
'left',
|
|
3361
|
-
'right',
|
|
3362
|
-
'top',
|
|
3363
|
-
'bottom',
|
|
3364
|
-
'diagonal'
|
|
3365
|
-
])border.append(document1.createElementNS(document1.documentElement.namespaceURI, name));
|
|
3366
|
-
return border;
|
|
3367
|
-
}
|
|
3368
|
-
function setXlsxBorderLine(document1, border, name, line) {
|
|
3369
|
-
removeXlsxChildren(border, name);
|
|
3370
|
-
const element = document1.createElementNS(document1.documentElement.namespaceURI, name);
|
|
3371
|
-
if (line) {
|
|
3372
|
-
element.setAttribute('style', line.style);
|
|
3373
|
-
const color = xlsxRgbColor(line.color);
|
|
3374
|
-
if (color) {
|
|
3375
|
-
const child = document1.createElementNS(document1.documentElement.namespaceURI, 'color');
|
|
3376
|
-
child.setAttribute('rgb', color);
|
|
3377
|
-
element.append(child);
|
|
3378
|
-
}
|
|
3379
|
-
}
|
|
3380
|
-
insertXlsxOrderedChild(border, element, borderChildOrder);
|
|
3381
|
-
}
|
|
3382
|
-
function writeXlsxAlignment(document1, xf, style) {
|
|
3383
|
-
let alignment = directChild(xf, 'alignment');
|
|
3384
|
-
if (!alignment) {
|
|
3385
|
-
alignment = document1.createElementNS(document1.documentElement.namespaceURI, 'alignment');
|
|
3386
|
-
xf.insertBefore(alignment, directChildren(xf).find((child)=>[
|
|
3387
|
-
'protection',
|
|
3388
|
-
'extLst'
|
|
3389
|
-
].includes(child.localName)) ?? null);
|
|
3390
|
-
}
|
|
3391
|
-
if (void 0 !== style.horizontal) alignment.setAttribute('horizontal', style.horizontal);
|
|
3392
|
-
if (void 0 !== style.vertical) alignment.setAttribute('vertical', style.vertical);
|
|
3393
|
-
if (void 0 !== style.wrapText) alignment.setAttribute('wrapText', style.wrapText ? '1' : '0');
|
|
3394
|
-
if (void 0 !== style.textRotation && Number.isInteger(style.textRotation) && (style.textRotation >= 0 && style.textRotation <= 180 || 255 === style.textRotation)) alignment.setAttribute('textRotation', String(style.textRotation));
|
|
3395
|
-
}
|
|
3396
|
-
function setXlsxValueChild(document1, parent, name, value, order) {
|
|
3397
|
-
removeXlsxChildren(parent, name);
|
|
3398
|
-
const child = document1.createElementNS(document1.documentElement.namespaceURI, name);
|
|
3399
|
-
child.setAttribute('val', value);
|
|
3400
|
-
insertXlsxOrderedChild(parent, child, order);
|
|
3401
|
-
}
|
|
3402
|
-
function setXlsxColorChild(document1, parent, color, order) {
|
|
3403
|
-
removeXlsxChildren(parent, 'color');
|
|
3404
|
-
const child = document1.createElementNS(document1.documentElement.namespaceURI, 'color');
|
|
3405
|
-
child.setAttribute('rgb', color);
|
|
3406
|
-
insertXlsxOrderedChild(parent, child, order);
|
|
3407
|
-
}
|
|
3408
|
-
function setXlsxToggleChild(document1, parent, name, enabled, order) {
|
|
3409
|
-
removeXlsxChildren(parent, name);
|
|
3410
|
-
if (!enabled) return;
|
|
3411
|
-
const child = document1.createElementNS(document1.documentElement.namespaceURI, name);
|
|
3412
|
-
child.setAttribute('val', '1');
|
|
3413
|
-
insertXlsxOrderedChild(parent, child, order);
|
|
3414
|
-
}
|
|
3415
|
-
function setXlsxUnderlineChild(document1, parent, style, order) {
|
|
3416
|
-
removeXlsxChildren(parent, 'u');
|
|
3417
|
-
if ('none' === style) return;
|
|
3418
|
-
const child = document1.createElementNS(document1.documentElement.namespaceURI, 'u');
|
|
3419
|
-
child.setAttribute('val', style);
|
|
3420
|
-
insertXlsxOrderedChild(parent, child, order);
|
|
3421
|
-
}
|
|
3422
|
-
function xlsxRgbColor(value) {
|
|
3423
|
-
if ('string' != typeof value) return null;
|
|
3424
|
-
const color = value.trim().replace('#', '').toUpperCase();
|
|
3425
|
-
if (/^[0-9A-F]{6}$/.test(color)) return `FF${color}`;
|
|
3426
|
-
if (/^[0-9A-F]{8}$/.test(color)) return color;
|
|
3427
|
-
if (/^[0-9A-F]{3}$/.test(color)) return `FF${[
|
|
3428
|
-
...color
|
|
3429
|
-
].map((character)=>character.repeat(2)).join('')}`;
|
|
3430
|
-
return null;
|
|
3431
|
-
}
|
|
3432
|
-
function removeXlsxChildren(parent, name) {
|
|
3433
|
-
for (const child of directChildren(parent, name))child.remove();
|
|
3434
|
-
}
|
|
3435
|
-
function insertXlsxOrderedChild(parent, child, order) {
|
|
3436
|
-
const requested = order.indexOf(child.localName);
|
|
3437
|
-
const anchor = directChildren(parent).find((candidate)=>order.indexOf(candidate.localName) > requested);
|
|
3438
|
-
parent.insertBefore(child, anchor ?? null);
|
|
3439
|
-
}
|
|
3440
|
-
const defaultThemeColors = [
|
|
3441
|
-
'ffffff',
|
|
3442
|
-
'000000',
|
|
3443
|
-
'e7e6e6',
|
|
3444
|
-
'44546a',
|
|
3445
|
-
'4472c4',
|
|
3446
|
-
'ed7d31',
|
|
3447
|
-
'a5a5a5',
|
|
3448
|
-
'ffc000',
|
|
3449
|
-
'5b9bd5',
|
|
3450
|
-
'70ad47',
|
|
3451
|
-
'0563c1',
|
|
3452
|
-
'954f72'
|
|
3453
|
-
];
|
|
3454
|
-
const themeColorNames = [
|
|
3455
|
-
'lt1',
|
|
3456
|
-
'dk1',
|
|
3457
|
-
'lt2',
|
|
3458
|
-
'dk2',
|
|
3459
|
-
'accent1',
|
|
3460
|
-
'accent2',
|
|
3461
|
-
'accent3',
|
|
3462
|
-
'accent4',
|
|
3463
|
-
'accent5',
|
|
3464
|
-
'accent6',
|
|
3465
|
-
'hlink',
|
|
3466
|
-
'folHlink'
|
|
3467
|
-
];
|
|
3468
|
-
const defaultIndexedColors = [
|
|
3469
|
-
'000000',
|
|
3470
|
-
'ffffff',
|
|
3471
|
-
'ff0000',
|
|
3472
|
-
'00ff00',
|
|
3473
|
-
'0000ff',
|
|
3474
|
-
'ffff00',
|
|
3475
|
-
'ff00ff',
|
|
3476
|
-
'00ffff',
|
|
3477
|
-
'000000',
|
|
3478
|
-
'ffffff',
|
|
3479
|
-
'ff0000',
|
|
3480
|
-
'00ff00',
|
|
3481
|
-
'0000ff',
|
|
3482
|
-
'ffff00',
|
|
3483
|
-
'ff00ff',
|
|
3484
|
-
'00ffff',
|
|
3485
|
-
'800000',
|
|
3486
|
-
'008000',
|
|
3487
|
-
'000080',
|
|
3488
|
-
'808000',
|
|
3489
|
-
'800080',
|
|
3490
|
-
'008080',
|
|
3491
|
-
'c0c0c0',
|
|
3492
|
-
'808080',
|
|
3493
|
-
'9999ff',
|
|
3494
|
-
'993366',
|
|
3495
|
-
'ffffcc',
|
|
3496
|
-
'ccffff',
|
|
3497
|
-
'660066',
|
|
3498
|
-
'ff8080',
|
|
3499
|
-
'0066cc',
|
|
3500
|
-
'ccccff',
|
|
3501
|
-
'000080',
|
|
3502
|
-
'ff00ff',
|
|
3503
|
-
'ffff00',
|
|
3504
|
-
'00ffff',
|
|
3505
|
-
'800080',
|
|
3506
|
-
'800000',
|
|
3507
|
-
'008080',
|
|
3508
|
-
'0000ff',
|
|
3509
|
-
'00ccff',
|
|
3510
|
-
'ccffff',
|
|
3511
|
-
'ccffcc',
|
|
3512
|
-
'ffff99',
|
|
3513
|
-
'99ccff',
|
|
3514
|
-
'ff99cc',
|
|
3515
|
-
'cc99ff',
|
|
3516
|
-
'ffcc99',
|
|
3517
|
-
'3366ff',
|
|
3518
|
-
'33cccc',
|
|
3519
|
-
'99cc00',
|
|
3520
|
-
'ffcc00',
|
|
3521
|
-
'ff9900',
|
|
3522
|
-
'ff6600',
|
|
3523
|
-
'666699',
|
|
3524
|
-
'969696',
|
|
3525
|
-
'003366',
|
|
3526
|
-
'339966',
|
|
3527
|
-
'003300',
|
|
3528
|
-
'333300',
|
|
3529
|
-
'993300',
|
|
3530
|
-
'993366',
|
|
3531
|
-
'333399',
|
|
3532
|
-
'333333'
|
|
3533
|
-
];
|
|
3534
|
-
function createXlsxColorResolver(styles, theme) {
|
|
3535
|
-
return {
|
|
3536
|
-
indexed: readIndexedColors(styles),
|
|
3537
|
-
theme: readThemeColors(theme)
|
|
3538
|
-
};
|
|
3539
|
-
}
|
|
3540
|
-
function resolveXlsxColor(element, resolver) {
|
|
3541
|
-
if (!element) return;
|
|
3542
|
-
const direct = normalizedHexColor(work_ooxml_package_attribute(element, 'rgb'));
|
|
3543
|
-
const themeIndex = boundedInteger(work_ooxml_package_attribute(element, 'theme'), 11);
|
|
3544
|
-
const indexed = boundedInteger(work_ooxml_package_attribute(element, 'indexed'), 65535);
|
|
3545
|
-
const automatic = work_xlsx_colors_booleanAttribute(element, 'auto');
|
|
3546
|
-
const source = direct ?? (null === themeIndex ? void 0 : resolver.theme[themeIndex]) ?? (null === indexed ? void 0 : resolver.indexed[indexed]) ?? (automatic ? '000000' : void 0);
|
|
3547
|
-
if (!source) return;
|
|
3548
|
-
const tint = Number(work_ooxml_package_attribute(element, 'tint'));
|
|
3549
|
-
return `#${Number.isFinite(tint) && tint >= -1 && tint <= 1 ? tintXlsxColor(source, tint) : source}`;
|
|
3550
|
-
}
|
|
3551
|
-
function readThemeColors(theme) {
|
|
3552
|
-
if (!theme) return defaultThemeColors;
|
|
3553
|
-
const scheme = firstDescendant(theme, 'clrScheme');
|
|
3554
|
-
if (!scheme) return defaultThemeColors;
|
|
3555
|
-
return themeColorNames.map((name, index)=>{
|
|
3556
|
-
const entry = directChild(scheme, name);
|
|
3557
|
-
const color = entry ? drawingColor(directChildren(entry)[0]) : void 0;
|
|
3558
|
-
return color ?? defaultThemeColors[index];
|
|
3559
|
-
});
|
|
3560
|
-
}
|
|
3561
|
-
function readIndexedColors(styles) {
|
|
3562
|
-
const indexed = firstDescendant(styles, 'indexedColors');
|
|
3563
|
-
if (!indexed) return defaultIndexedColors;
|
|
3564
|
-
const colors = directChildren(indexed, 'rgbColor').map((element)=>normalizedHexColor(work_ooxml_package_attribute(element, 'rgb')));
|
|
3565
|
-
return colors.every(Boolean) ? colors : defaultIndexedColors;
|
|
3566
|
-
}
|
|
3567
|
-
function drawingColor(element) {
|
|
3568
|
-
if (!element) return;
|
|
3569
|
-
return normalizedHexColor('sysClr' === element.localName ? work_ooxml_package_attribute(element, 'lastClr') : work_ooxml_package_attribute(element, 'val'));
|
|
3570
|
-
}
|
|
3571
|
-
function tintXlsxColor(color, tint) {
|
|
3572
|
-
const [hue, saturation, lightness] = rgbToHsl([
|
|
3573
|
-
0,
|
|
3574
|
-
2,
|
|
3575
|
-
4
|
|
3576
|
-
].map((offset)=>Number.parseInt(color.slice(offset, offset + 2), 16) / 255));
|
|
3577
|
-
const tintedLightness = tint < 0 ? lightness * (1 + tint) : 1 - (1 - lightness) * (1 - tint);
|
|
3578
|
-
return hslToRgb(hue, saturation, tintedLightness).map((channel)=>Math.round(255 * channel)).map((channel)=>channel.toString(16).padStart(2, '0')).join('');
|
|
3579
|
-
}
|
|
3580
|
-
function rgbToHsl([red, green, blue]) {
|
|
3581
|
-
const maximum = Math.max(red, green, blue);
|
|
3582
|
-
const minimum = Math.min(red, green, blue);
|
|
3583
|
-
const delta = maximum - minimum;
|
|
3584
|
-
const lightness = (maximum + minimum) / 2;
|
|
3585
|
-
if (0 === delta) return [
|
|
3586
|
-
0,
|
|
3587
|
-
0,
|
|
3588
|
-
lightness
|
|
3589
|
-
];
|
|
3590
|
-
const saturation = delta / (1 - Math.abs(2 * lightness - 1));
|
|
3591
|
-
const hue = maximum === red ? ((green - blue) / delta + (green < blue ? 6 : 0)) / 6 : maximum === green ? ((blue - red) / delta + 2) / 6 : ((red - green) / delta + 4) / 6;
|
|
3592
|
-
return [
|
|
3593
|
-
hue,
|
|
3594
|
-
saturation,
|
|
3595
|
-
lightness
|
|
3596
|
-
];
|
|
3597
|
-
}
|
|
3598
|
-
function hslToRgb(hue, saturation, lightness) {
|
|
3599
|
-
if (0 === saturation) return [
|
|
3600
|
-
lightness,
|
|
3601
|
-
lightness,
|
|
3602
|
-
lightness
|
|
3603
|
-
];
|
|
3604
|
-
const chroma = 2 * saturation * (lightness < 0.5 ? lightness : 1 - lightness);
|
|
3605
|
-
const minimum = lightness - chroma / 2;
|
|
3606
|
-
const channels = [
|
|
3607
|
-
minimum,
|
|
3608
|
-
minimum,
|
|
3609
|
-
minimum
|
|
3610
|
-
];
|
|
3611
|
-
const sector = 6 * hue;
|
|
3612
|
-
switch(Math.floor(sector)){
|
|
3613
|
-
case 0:
|
|
3614
|
-
case 6:
|
|
3615
|
-
channels[0] += chroma;
|
|
3616
|
-
channels[1] += chroma * sector;
|
|
3617
|
-
break;
|
|
3618
|
-
case 1:
|
|
3619
|
-
channels[0] += chroma * (2 - sector);
|
|
3620
|
-
channels[1] += chroma;
|
|
3621
|
-
break;
|
|
3622
|
-
case 2:
|
|
3623
|
-
channels[1] += chroma;
|
|
3624
|
-
channels[2] += chroma * (sector - 2);
|
|
3625
|
-
break;
|
|
3626
|
-
case 3:
|
|
3627
|
-
channels[1] += chroma * (4 - sector);
|
|
3628
|
-
channels[2] += chroma;
|
|
3629
|
-
break;
|
|
3630
|
-
case 4:
|
|
3631
|
-
channels[0] += chroma * (sector - 4);
|
|
3632
|
-
channels[2] += chroma;
|
|
3633
|
-
break;
|
|
3634
|
-
case 5:
|
|
3635
|
-
channels[0] += chroma;
|
|
3636
|
-
channels[2] += chroma * (6 - sector);
|
|
3637
|
-
break;
|
|
3638
|
-
}
|
|
3639
|
-
return channels;
|
|
3640
|
-
}
|
|
3641
|
-
function normalizedHexColor(value) {
|
|
3642
|
-
if (!value || !/^[0-9a-f]{6,8}$/i.test(value)) return;
|
|
3643
|
-
return value.slice(-6).toLowerCase();
|
|
3644
|
-
}
|
|
3645
|
-
function boundedInteger(value, maximum) {
|
|
3646
|
-
if (null === value || !/^\d+$/.test(value)) return null;
|
|
3647
|
-
const parsed = Number(value);
|
|
3648
|
-
return Number.isSafeInteger(parsed) && parsed <= maximum ? parsed : null;
|
|
3649
|
-
}
|
|
3650
|
-
function work_xlsx_colors_booleanAttribute(element, name) {
|
|
3651
|
-
const value = work_ooxml_package_attribute(element, name)?.trim().toLowerCase();
|
|
3652
|
-
return '1' === value || 'true' === value || 'on' === value;
|
|
3653
|
-
}
|
|
3654
|
-
const THEME_COLOR_NAMES = [
|
|
3655
|
-
'lt1',
|
|
3656
|
-
'dk1',
|
|
3657
|
-
'lt2',
|
|
3658
|
-
'dk2',
|
|
3659
|
-
'accent1',
|
|
3660
|
-
'accent2',
|
|
3661
|
-
'accent3',
|
|
3662
|
-
'accent4',
|
|
3663
|
-
'accent5',
|
|
3664
|
-
'accent6',
|
|
3665
|
-
'hlink',
|
|
3666
|
-
'folHlink'
|
|
3667
|
-
];
|
|
3668
|
-
const MAX_INDEXED_COLOR = 255;
|
|
3669
|
-
function readXlsxSemanticColorOrigin(element, colors) {
|
|
3670
|
-
if (!element || work_ooxml_package_attribute(element, 'rgb')) return;
|
|
3671
|
-
const renderedColor = resolveXlsxColor(element, colors);
|
|
3672
|
-
if (!renderedColor) return;
|
|
3673
|
-
const tint = boundedTint(work_ooxml_package_attribute(element, 'tint'));
|
|
3674
|
-
const theme = work_xlsx_cell_style_origin_boundedInteger(work_ooxml_package_attribute(element, 'theme'), THEME_COLOR_NAMES.length - 1);
|
|
3675
|
-
if (null !== theme && colors.theme[theme]) return {
|
|
3676
|
-
kind: 'theme',
|
|
3677
|
-
baseColor: `#${colors.theme[theme]}`,
|
|
3678
|
-
index: theme,
|
|
3679
|
-
renderedColor,
|
|
3680
|
-
...null === tint ? {} : {
|
|
3681
|
-
tint
|
|
3682
|
-
}
|
|
3683
|
-
};
|
|
3684
|
-
const indexed = work_xlsx_cell_style_origin_boundedInteger(work_ooxml_package_attribute(element, 'indexed'), MAX_INDEXED_COLOR);
|
|
3685
|
-
if (null !== indexed && colors.indexed[indexed]) return {
|
|
3686
|
-
kind: 'indexed',
|
|
3687
|
-
baseColor: `#${colors.indexed[indexed]}`,
|
|
3688
|
-
index: indexed,
|
|
3689
|
-
renderedColor,
|
|
3690
|
-
...null === tint ? {} : {
|
|
3691
|
-
tint
|
|
3692
|
-
}
|
|
3693
|
-
};
|
|
3694
|
-
if (xlsxBooleanAttribute(element, 'auto')) return {
|
|
3695
|
-
kind: 'automatic',
|
|
3696
|
-
baseColor: '#000000',
|
|
3697
|
-
renderedColor,
|
|
3698
|
-
...null === tint ? {} : {
|
|
3699
|
-
tint
|
|
3700
|
-
}
|
|
3701
|
-
};
|
|
3702
|
-
}
|
|
3703
|
-
function withXlsxCellStyleOrigin(cell, origin) {
|
|
3704
|
-
return origin && xlsxCellStyleOriginHasValues(origin) ? {
|
|
3705
|
-
...cell,
|
|
3706
|
-
a3sXlsxStyleOrigin: origin
|
|
3707
|
-
} : cell;
|
|
3708
|
-
}
|
|
3709
|
-
function xlsxCellStyleOrigin(cell) {
|
|
3710
|
-
const candidate = cell?.a3sXlsxStyleOrigin;
|
|
3711
|
-
if (!work_xlsx_cell_style_origin_isRecord(candidate)) return;
|
|
3712
|
-
const fontColor = normalizedXlsxSemanticColor(candidate.fontColor);
|
|
3713
|
-
const fillColor = normalizedXlsxSemanticColor(candidate.fillColor);
|
|
3714
|
-
const borderColors = normalizedBorderColors(candidate.borderColors);
|
|
3715
|
-
const origin = {
|
|
3716
|
-
...fontColor ? {
|
|
3717
|
-
fontColor
|
|
3718
|
-
} : {},
|
|
3719
|
-
...fillColor ? {
|
|
3720
|
-
fillColor
|
|
3721
|
-
} : {},
|
|
3722
|
-
...borderColors ? {
|
|
3723
|
-
borderColors
|
|
3724
|
-
} : {}
|
|
3725
|
-
};
|
|
3726
|
-
return xlsxCellStyleOriginHasValues(origin) ? origin : void 0;
|
|
3727
|
-
}
|
|
3728
|
-
function xlsxSemanticColorMatchesValue(origin, value) {
|
|
3729
|
-
return normalizedColor(value) === origin.renderedColor.toLowerCase();
|
|
3730
|
-
}
|
|
3731
|
-
function xlsxColorElementMatchesOrigin(element, origin) {
|
|
3732
|
-
if (!element || work_ooxml_package_attribute(element, 'rgb')) return false;
|
|
3733
|
-
if ('theme' === origin.kind) {
|
|
3734
|
-
if (work_ooxml_package_attribute(element, 'theme') !== String(origin.index)) return false;
|
|
3735
|
-
} else if ('indexed' === origin.kind) {
|
|
3736
|
-
if (work_ooxml_package_attribute(element, 'indexed') !== String(origin.index)) return false;
|
|
3737
|
-
} else if (!xlsxBooleanAttribute(element, 'auto')) return false;
|
|
3738
|
-
const tint = boundedTint(work_ooxml_package_attribute(element, 'tint'));
|
|
3739
|
-
return tint === (origin.tint ?? null);
|
|
3740
|
-
}
|
|
3741
|
-
function applyXlsxSemanticColorOrigin(element, origin) {
|
|
3742
|
-
for (const name of [
|
|
3743
|
-
'rgb',
|
|
3744
|
-
'theme',
|
|
3745
|
-
'indexed',
|
|
3746
|
-
'auto',
|
|
3747
|
-
'tint'
|
|
3748
|
-
])element.removeAttribute(name);
|
|
3749
|
-
if ('theme' === origin.kind) element.setAttribute('theme', String(origin.index));
|
|
3750
|
-
else if ('indexed' === origin.kind) element.setAttribute('indexed', String(origin.index));
|
|
3751
|
-
else element.setAttribute('auto', '1');
|
|
3752
|
-
if (void 0 !== origin.tint) element.setAttribute('tint', String(origin.tint));
|
|
3753
|
-
}
|
|
3754
|
-
function xlsxSemanticColorOriginKey(origin) {
|
|
3755
|
-
return origin ? `${origin.kind}:${'index' in origin ? origin.index : ''}:${origin.baseColor}:${origin.renderedColor}:${origin.tint ?? ''}` : '';
|
|
3756
|
-
}
|
|
3757
|
-
function xlsxSemanticColorOriginSupported(origin, palette) {
|
|
3758
|
-
if ('automatic' === origin.kind) return true;
|
|
3759
|
-
return palette?.[origin.kind].get(origin.index)?.toLowerCase() === origin.baseColor.toLowerCase();
|
|
3760
|
-
}
|
|
3761
|
-
function prepareXlsxSemanticPalette(styles, theme, origins) {
|
|
3762
|
-
const candidates = semanticPaletteCandidates(origins);
|
|
3763
|
-
const supportedTheme = new Map();
|
|
3764
|
-
let themeChanged = false;
|
|
3765
|
-
const scheme = theme ? firstDescendant(theme, 'clrScheme') : void 0;
|
|
3766
|
-
for (const [index, color] of candidates.theme){
|
|
3767
|
-
const name = THEME_COLOR_NAMES[index];
|
|
3768
|
-
const entry = name && scheme ? directChild(scheme, name) : void 0;
|
|
3769
|
-
if (entry) {
|
|
3770
|
-
themeChanged = writeThemeColor(entry, color) || themeChanged;
|
|
3771
|
-
supportedTheme.set(index, color);
|
|
3772
|
-
}
|
|
3773
|
-
}
|
|
3774
|
-
const supportedIndexed = new Map();
|
|
3775
|
-
let stylesChanged = false;
|
|
3776
|
-
if (candidates.indexed.size) {
|
|
3777
|
-
const colors = ensureXlsxStyleCollection(styles, 'colors', [
|
|
3778
|
-
'extLst'
|
|
3779
|
-
]);
|
|
3780
|
-
let indexedColors = directChild(colors, 'indexedColors');
|
|
3781
|
-
if (!indexedColors) {
|
|
3782
|
-
indexedColors = styles.createElementNS(styles.documentElement.namespaceURI, 'indexedColors');
|
|
3783
|
-
colors.prepend(indexedColors);
|
|
3784
|
-
stylesChanged = true;
|
|
3785
|
-
}
|
|
3786
|
-
const resolver = createXlsxColorResolver(styles, theme);
|
|
3787
|
-
const highestIndex = Math.max(...candidates.indexed.keys());
|
|
3788
|
-
while(directChildren(indexedColors, 'rgbColor').length <= highestIndex){
|
|
3789
|
-
const index = directChildren(indexedColors, 'rgbColor').length;
|
|
3790
|
-
const element = styles.createElementNS(styles.documentElement.namespaceURI, 'rgbColor');
|
|
3791
|
-
element.setAttribute('rgb', `FF${(resolver.indexed[index] ?? '000000').toUpperCase()}`);
|
|
3792
|
-
indexedColors.append(element);
|
|
3793
|
-
stylesChanged = true;
|
|
3794
|
-
}
|
|
3795
|
-
const entries = directChildren(indexedColors, 'rgbColor');
|
|
3796
|
-
for (const [index, color] of candidates.indexed){
|
|
3797
|
-
const expected = `FF${color.slice(1).toUpperCase()}`;
|
|
3798
|
-
const entry = entries[index];
|
|
3799
|
-
if (entry) {
|
|
3800
|
-
if (work_ooxml_package_attribute(entry, 'rgb')?.toUpperCase() !== expected) {
|
|
3801
|
-
entry.setAttribute('rgb', expected);
|
|
3802
|
-
stylesChanged = true;
|
|
3803
|
-
}
|
|
3804
|
-
supportedIndexed.set(index, color);
|
|
3805
|
-
}
|
|
3806
|
-
}
|
|
3807
|
-
}
|
|
3808
|
-
return {
|
|
3809
|
-
palette: {
|
|
3810
|
-
indexed: supportedIndexed,
|
|
3811
|
-
theme: supportedTheme
|
|
3812
|
-
},
|
|
3813
|
-
stylesChanged,
|
|
3814
|
-
themeChanged
|
|
3815
|
-
};
|
|
3816
|
-
}
|
|
3817
|
-
function semanticPaletteCandidates(origins) {
|
|
3818
|
-
const theme = new Map();
|
|
3819
|
-
const indexed = new Map();
|
|
3820
|
-
const themeConflicts = new Set();
|
|
3821
|
-
const indexedConflicts = new Set();
|
|
3822
|
-
for (const origin of origins)for (const color of xlsxCellStyleOriginColors(origin)){
|
|
3823
|
-
if ('automatic' === color.kind) continue;
|
|
3824
|
-
const target = 'theme' === color.kind ? theme : indexed;
|
|
3825
|
-
const conflicts = 'theme' === color.kind ? themeConflicts : indexedConflicts;
|
|
3826
|
-
const current = target.get(color.index);
|
|
3827
|
-
if (current && current.toLowerCase() !== color.baseColor.toLowerCase()) conflicts.add(color.index);
|
|
3828
|
-
else if (!current) target.set(color.index, color.baseColor);
|
|
3829
|
-
}
|
|
3830
|
-
for (const index of themeConflicts)theme.delete(index);
|
|
3831
|
-
for (const index of indexedConflicts)indexed.delete(index);
|
|
3832
|
-
return {
|
|
3833
|
-
indexed,
|
|
3834
|
-
theme
|
|
3835
|
-
};
|
|
3836
|
-
}
|
|
3837
|
-
function xlsxCellStyleOriginColors(origin) {
|
|
3838
|
-
return [
|
|
3839
|
-
origin.fontColor,
|
|
3840
|
-
origin.fillColor,
|
|
3841
|
-
...Object.values(origin.borderColors ?? {})
|
|
3842
|
-
].filter((value)=>Boolean(value));
|
|
3843
|
-
}
|
|
3844
|
-
function writeThemeColor(entry, color) {
|
|
3845
|
-
const current = directChildren(entry)[0];
|
|
3846
|
-
if (current?.localName === 'srgbClr' && work_ooxml_package_attribute(current, 'val')?.toLowerCase() === color.slice(1).toLowerCase()) return false;
|
|
3847
|
-
for (const child of directChildren(entry))child.remove();
|
|
3848
|
-
const qualifiedName = entry.prefix ? `${entry.prefix}:srgbClr` : 'srgbClr';
|
|
3849
|
-
const replacement = entry.ownerDocument.createElementNS(entry.namespaceURI, qualifiedName);
|
|
3850
|
-
replacement.setAttribute('val', color.slice(1).toUpperCase());
|
|
3851
|
-
entry.append(replacement);
|
|
3852
|
-
return true;
|
|
3853
|
-
}
|
|
3854
|
-
function normalizedBorderColors(value) {
|
|
3855
|
-
if (!work_xlsx_cell_style_origin_isRecord(value)) return;
|
|
3856
|
-
const result = {};
|
|
3857
|
-
for (const side of [
|
|
3858
|
-
'bottom',
|
|
3859
|
-
'diagonal',
|
|
3860
|
-
'left',
|
|
3861
|
-
'right',
|
|
3862
|
-
'top'
|
|
3863
|
-
]){
|
|
3864
|
-
const color = normalizedXlsxSemanticColor(value[side]);
|
|
3865
|
-
if (color) result[side] = color;
|
|
3866
|
-
}
|
|
3867
|
-
return Object.keys(result).length ? result : void 0;
|
|
3868
|
-
}
|
|
3869
|
-
function normalizedXlsxSemanticColor(value) {
|
|
3870
|
-
if (!work_xlsx_cell_style_origin_isRecord(value)) return;
|
|
3871
|
-
const baseColor = normalizedColor(value.baseColor);
|
|
3872
|
-
const renderedColor = normalizedColor(value.renderedColor);
|
|
3873
|
-
const tint = normalizedTint(value.tint);
|
|
3874
|
-
if (!baseColor || !renderedColor || void 0 === tint) return;
|
|
3875
|
-
if ('automatic' === value.kind) return {
|
|
3876
|
-
kind: 'automatic',
|
|
3877
|
-
baseColor,
|
|
3878
|
-
renderedColor,
|
|
3879
|
-
...null === tint ? {} : {
|
|
3880
|
-
tint
|
|
3881
|
-
}
|
|
3882
|
-
};
|
|
3883
|
-
const maximum = 'theme' === value.kind ? THEME_COLOR_NAMES.length - 1 : MAX_INDEXED_COLOR;
|
|
3884
|
-
const index = boundedNumber(value.index, maximum);
|
|
3885
|
-
if ('theme' !== value.kind && 'indexed' !== value.kind || null === index) return;
|
|
3886
|
-
return {
|
|
3887
|
-
kind: value.kind,
|
|
3888
|
-
baseColor,
|
|
3889
|
-
index,
|
|
3890
|
-
renderedColor,
|
|
3891
|
-
...null === tint ? {} : {
|
|
3892
|
-
tint
|
|
3893
|
-
}
|
|
3894
|
-
};
|
|
3895
|
-
}
|
|
3896
|
-
function xlsxCellStyleOriginHasValues(origin) {
|
|
3897
|
-
return Boolean(origin.fontColor || origin.fillColor || Object.keys(origin.borderColors ?? {}).length);
|
|
3898
|
-
}
|
|
3899
|
-
function normalizedColor(value) {
|
|
3900
|
-
const rgb = xlsxRgbColor(value);
|
|
3901
|
-
return rgb ? `#${rgb.slice(-6).toLowerCase()}` : null;
|
|
3902
|
-
}
|
|
3903
|
-
function normalizedTint(value) {
|
|
3904
|
-
if (void 0 === value) return null;
|
|
3905
|
-
return 'number' == typeof value && Number.isFinite(value) && value >= -1 && value <= 1 ? value : void 0;
|
|
3906
|
-
}
|
|
3907
|
-
function boundedTint(value) {
|
|
3908
|
-
if (null === value) return null;
|
|
3909
|
-
const tint = Number(value);
|
|
3910
|
-
return Number.isFinite(tint) && tint >= -1 && tint <= 1 ? tint : null;
|
|
3911
|
-
}
|
|
3912
|
-
function work_xlsx_cell_style_origin_boundedInteger(value, maximum) {
|
|
3913
|
-
if (null === value || !/^\d+$/.test(value)) return null;
|
|
3914
|
-
return boundedNumber(Number(value), maximum);
|
|
3915
|
-
}
|
|
3916
|
-
function boundedNumber(value, maximum) {
|
|
3917
|
-
return 'number' == typeof value && Number.isSafeInteger(value) && value >= 0 && value <= maximum ? value : null;
|
|
3918
|
-
}
|
|
3919
|
-
function xlsxBooleanAttribute(element, name) {
|
|
3920
|
-
const value = work_ooxml_package_attribute(element, name)?.trim().toLowerCase();
|
|
3921
|
-
return '1' === value || 'true' === value || 'on' === value;
|
|
3922
|
-
}
|
|
3923
|
-
function work_xlsx_cell_style_origin_isRecord(value) {
|
|
3924
|
-
return 'object' == typeof value && null !== value && !Array.isArray(value);
|
|
3925
|
-
}
|
|
3926
|
-
function hasXlsxDirectFontStyle(cell) {
|
|
3927
|
-
return Boolean(void 0 !== cell.bl || void 0 !== cell.it || void 0 !== cell.un || void 0 !== cell.cl || void 0 !== cell.ff || void 0 !== cell.fs || void 0 !== cell.fc);
|
|
3928
|
-
}
|
|
3929
|
-
function directXlsxFontStyle(cell) {
|
|
3930
|
-
const color = void 0 !== cell.fc ? xlsxRgbColor(cell.fc) : null;
|
|
3931
|
-
return {
|
|
3932
|
-
...void 0 !== cell.bl ? {
|
|
3933
|
-
bold: 1 === Number(cell.bl)
|
|
3934
|
-
} : {},
|
|
3935
|
-
...color ? {
|
|
3936
|
-
color
|
|
3937
|
-
} : {},
|
|
3938
|
-
...void 0 !== cell.it ? {
|
|
3939
|
-
italic: 1 === Number(cell.it)
|
|
3940
|
-
} : {},
|
|
3941
|
-
...'string' == typeof cell.ff && cell.ff.trim() ? {
|
|
3942
|
-
name: cell.ff.trim()
|
|
3943
|
-
} : {},
|
|
3944
|
-
...'number' == typeof cell.fs && Number.isFinite(cell.fs) && cell.fs > 0 ? {
|
|
3945
|
-
size: cell.fs
|
|
3946
|
-
} : {},
|
|
3947
|
-
...void 0 !== cell.cl ? {
|
|
3948
|
-
strike: 1 === Number(cell.cl)
|
|
3949
|
-
} : {},
|
|
3950
|
-
...void 0 !== cell.un ? {
|
|
3951
|
-
underline: spreadsheetUnderlineStyle(cell.un)
|
|
3952
|
-
} : {}
|
|
3953
|
-
};
|
|
3954
|
-
}
|
|
3955
|
-
function directXlsxAlignment(cell) {
|
|
3956
|
-
const alignment = {};
|
|
3957
|
-
if (void 0 !== cell.ht) alignment.horizontal = 0 === Number(cell.ht) ? 'center' : 2 === Number(cell.ht) ? 'right' : 'left';
|
|
3958
|
-
if (void 0 !== cell.vt) alignment.vertical = 0 === Number(cell.vt) ? 'center' : 1 === Number(cell.vt) ? 'top' : 'bottom';
|
|
3959
|
-
if (void 0 !== cell.tb) alignment.wrapText = '2' === cell.tb;
|
|
3960
|
-
const rotation = spreadsheetTextOrientationXlsxValueFromCell(cell);
|
|
3961
|
-
if (null !== rotation) alignment.textRotation = rotation;
|
|
3962
|
-
return Object.keys(alignment).length ? alignment : null;
|
|
3963
|
-
}
|
|
3964
|
-
function xlsxStyleCollectionIndex(collection, childName, value) {
|
|
3965
|
-
const index = work_xlsx_cell_style_values_nonNegativeInteger(value) ?? 0;
|
|
3966
|
-
return directChildren(collection, childName)[index] ? index : 0;
|
|
3967
|
-
}
|
|
3968
|
-
function xlsxColorMatches(element, value, colors, fallback) {
|
|
3969
|
-
const rgb = xlsxRgbColor(value);
|
|
3970
|
-
const resolved = resolveXlsxColor(element, colors) ?? fallback;
|
|
3971
|
-
return Boolean(rgb && resolved && `#${rgb.slice(-6).toLowerCase()}` === resolved.toLowerCase());
|
|
3972
|
-
}
|
|
3973
|
-
function xlsxToggleEnabled(element) {
|
|
3974
|
-
if (!element) return false;
|
|
3975
|
-
const value = work_ooxml_package_attribute(element, 'val')?.trim().toLowerCase();
|
|
3976
|
-
return '0' !== value && 'false' !== value && 'off' !== value;
|
|
3977
|
-
}
|
|
3978
|
-
function xlsxUnderlineStyle(element) {
|
|
3979
|
-
return element ? spreadsheetUnderlineStyle(spreadsheetUnderlineCellValueFromXlsx(work_ooxml_package_attribute(element, 'val'))) : 'none';
|
|
3980
|
-
}
|
|
3981
|
-
function xlsxBorderLineMatches(element, line, colors, semanticColor) {
|
|
3982
|
-
const style = element ? work_ooxml_package_attribute(element, 'style') : null;
|
|
3983
|
-
if (!line) return !style;
|
|
3984
|
-
return style === line.style && (semanticColor ? xlsxColorElementMatchesOrigin(element ? directChild(element, 'color') : void 0, semanticColor) : xlsxColorMatches(element ? directChild(element, 'color') : void 0, line.color, colors, '#000000'));
|
|
3985
|
-
}
|
|
3986
|
-
function activeXlsxSemanticColorOrigin(origin, value, palette) {
|
|
3987
|
-
return origin && xlsxSemanticColorMatchesValue(origin, value) && xlsxSemanticColorOriginSupported(origin, palette) ? origin : void 0;
|
|
3988
|
-
}
|
|
3989
|
-
function work_xlsx_cell_style_values_xlsxBooleanAttribute(element, name) {
|
|
3990
|
-
if (!element) return false;
|
|
3991
|
-
const value = work_ooxml_package_attribute(element, name)?.trim().toLowerCase();
|
|
3992
|
-
return '1' === value || 'true' === value || 'on' === value;
|
|
3993
|
-
}
|
|
3994
|
-
function xlsxAlignmentMatches(xf, style) {
|
|
3995
|
-
const alignment = directChild(xf, 'alignment');
|
|
3996
|
-
if (void 0 !== style.horizontal && work_ooxml_package_attribute(alignment ?? xf, 'horizontal') !== style.horizontal) return false;
|
|
3997
|
-
if (void 0 !== style.vertical && work_ooxml_package_attribute(alignment ?? xf, 'vertical') !== style.vertical) return false;
|
|
3998
|
-
if (void 0 !== style.wrapText && (!alignment || null === work_ooxml_package_attribute(alignment, 'wrapText') || work_xlsx_cell_style_values_xlsxBooleanAttribute(alignment, 'wrapText') !== style.wrapText)) return false;
|
|
3999
|
-
if (void 0 !== style.textRotation) {
|
|
4000
|
-
const rotation = work_xlsx_cell_style_values_nonNegativeInteger(alignment ? work_ooxml_package_attribute(alignment, 'textRotation') : null);
|
|
4001
|
-
if (rotation !== style.textRotation) return false;
|
|
4002
|
-
}
|
|
4003
|
-
return true;
|
|
4004
|
-
}
|
|
4005
|
-
function work_xlsx_cell_style_values_nonNegativeInteger(value) {
|
|
4006
|
-
if (null === value || !/^\d+$/.test(value)) return null;
|
|
4007
|
-
const parsed = Number(value);
|
|
4008
|
-
return Number.isSafeInteger(parsed) ? parsed : null;
|
|
4009
|
-
}
|
|
4010
3282
|
const fontChildOrder = [
|
|
4011
3283
|
'name',
|
|
4012
3284
|
'charset',
|
|
@@ -6073,22 +5345,24 @@ const DIAGNOSTIC_WORKSHEET_ELEMENTS = new Set([
|
|
|
6073
5345
|
'rowBreaks',
|
|
6074
5346
|
'colBreaks'
|
|
6075
5347
|
]);
|
|
6076
|
-
const WORKSHEET_SCAN_PATTERN = /<(?:[A-Za-z_][\w.-]*:)?(?:(cols|f|pane|dataValidation|conditionalFormatting|sheetProtection|protectedRange|rowBreaks|colBreaks|pageSetup|pageMargins|printOptions|headerFooter|pageSetUpPr|drawing|tableParts)(?=[\s/>])|(row)(?=[\s/>])[^>]*\s(?:collapsed|customFormat|customHeight|hidden|ht|outlineLevel|thickBot|thickTop)\s*=|(c)(?=[\s/>])[^>]*\ss\s
|
|
5348
|
+
const WORKSHEET_SCAN_PATTERN = /<(?:[A-Za-z_][\w.-]*:)?(?:(cols|f|pane|dataValidation|conditionalFormatting|sheetProtection|protectedRange|rowBreaks|colBreaks|pageSetup|pageMargins|printOptions|headerFooter|pageSetUpPr|drawing|tableParts)(?=[\s/>])|(row)(?=[\s/>])[^>]*\s(?:collapsed|customFormat|customHeight|hidden|ht|outlineLevel|thickBot|thickTop)\s*=|(c)(?=[\s/>])[^>]*\ss\s*=|(r)(?=[\s/>]))/g;
|
|
6077
5349
|
function scanXlsxWorksheetXml(source) {
|
|
6078
5350
|
let hasDirectCellStyles = false;
|
|
6079
5351
|
let hasDiagnosticFeatures = false;
|
|
6080
5352
|
let hasFormulaFeatures = false;
|
|
6081
5353
|
let hasImportedFeatures = false;
|
|
5354
|
+
let hasRichTextCells = false;
|
|
6082
5355
|
let requiresSheetJsCellStyles = false;
|
|
6083
5356
|
WORKSHEET_SCAN_PATTERN.lastIndex = 0;
|
|
6084
5357
|
for(let match = WORKSHEET_SCAN_PATTERN.exec(source); match;){
|
|
6085
5358
|
const element = match[1];
|
|
6086
5359
|
if (match[3]) hasDirectCellStyles = true;
|
|
5360
|
+
if (match[4]) hasRichTextCells = true;
|
|
6087
5361
|
if (match[2] || match[3] || 'cols' === element) requiresSheetJsCellStyles = true;
|
|
6088
5362
|
if ('f' === element) hasFormulaFeatures = true;
|
|
6089
5363
|
if (element && IMPORTED_WORKSHEET_ELEMENTS.has(element)) hasImportedFeatures = true;
|
|
6090
5364
|
if (element && DIAGNOSTIC_WORKSHEET_ELEMENTS.has(element)) hasDiagnosticFeatures = true;
|
|
6091
|
-
if (hasDirectCellStyles && hasDiagnosticFeatures && hasFormulaFeatures && hasImportedFeatures && requiresSheetJsCellStyles) break;
|
|
5365
|
+
if (hasDirectCellStyles && hasDiagnosticFeatures && hasFormulaFeatures && hasImportedFeatures && hasRichTextCells && requiresSheetJsCellStyles) break;
|
|
6092
5366
|
match = WORKSHEET_SCAN_PATTERN.exec(source);
|
|
6093
5367
|
}
|
|
6094
5368
|
WORKSHEET_SCAN_PATTERN.lastIndex = 0;
|
|
@@ -6097,6 +5371,7 @@ function scanXlsxWorksheetXml(source) {
|
|
|
6097
5371
|
hasDiagnosticFeatures,
|
|
6098
5372
|
hasFormulaFeatures,
|
|
6099
5373
|
hasImportedFeatures,
|
|
5374
|
+
hasRichTextCells,
|
|
6100
5375
|
requiresSheetJsCellStyles
|
|
6101
5376
|
};
|
|
6102
5377
|
}
|
|
@@ -6736,6 +6011,15 @@ async function readXlsxSheetFeaturesFromPackage(archive, worksheetScans) {
|
|
|
6736
6011
|
const uses1904DateSystem = xlsxUses1904DateSystem(workbook);
|
|
6737
6012
|
const styles = archive.has('xl/styles.xml') ? await archive.xml('xl/styles.xml') : null;
|
|
6738
6013
|
const theme = archive.has('xl/theme/theme1.xml') ? await archive.xml('xl/theme/theme1.xml') : null;
|
|
6014
|
+
const sharedStringsSource = archive.has('xl/sharedStrings.xml') ? await archive.text('xl/sharedStrings.xml') : null;
|
|
6015
|
+
const sharedStrings = sharedStringsSource && xmlContainsAnyElement(sharedStringsSource, [
|
|
6016
|
+
'r'
|
|
6017
|
+
]) ? parseXml(sharedStringsSource, 'xl/sharedStrings.xml') : null;
|
|
6018
|
+
const richText = createXlsxRichTextReadContext({
|
|
6019
|
+
sharedStrings,
|
|
6020
|
+
styles,
|
|
6021
|
+
theme
|
|
6022
|
+
});
|
|
6739
6023
|
const differentialFormats = readXlsxDifferentialFormats(styles);
|
|
6740
6024
|
const features = new Map();
|
|
6741
6025
|
const imageBudget = {
|
|
@@ -6744,13 +6028,14 @@ async function readXlsxSheetFeaturesFromPackage(archive, worksheetScans) {
|
|
|
6744
6028
|
for (const [sheetName, partPath] of worksheetParts){
|
|
6745
6029
|
if (!archive.has(partPath)) continue;
|
|
6746
6030
|
const scan = worksheetScans?.[partPath];
|
|
6747
|
-
if (scan && !scan.hasImportedFeatures && !scan.hasDirectCellStyles) {
|
|
6031
|
+
if (scan && !scan.hasImportedFeatures && !scan.hasDirectCellStyles && !scan.hasRichTextCells && !richText.hasRichSharedStrings) {
|
|
6748
6032
|
features.set(sheetName, emptyXlsxSheetFeatures());
|
|
6749
6033
|
continue;
|
|
6750
6034
|
}
|
|
6751
6035
|
const source = await archive.text(partPath);
|
|
6752
6036
|
const detected = scan ?? scanXlsxWorksheetXml(source);
|
|
6753
|
-
|
|
6037
|
+
const mayReferenceRichSharedString = richText.hasRichSharedStrings && xlsxWorksheetMayReferenceSharedStrings(source);
|
|
6038
|
+
if (!detected.hasImportedFeatures && !detected.hasDirectCellStyles && !detected.hasRichTextCells && !mayReferenceRichSharedString) {
|
|
6754
6039
|
features.set(sheetName, emptyXlsxSheetFeatures());
|
|
6755
6040
|
continue;
|
|
6756
6041
|
}
|
|
@@ -6765,11 +6050,15 @@ async function readXlsxSheetFeaturesFromPackage(archive, worksheetScans) {
|
|
|
6765
6050
|
pageSetup: readXlsxPageSetup(document1),
|
|
6766
6051
|
images: await readXlsxWorksheetImages(archive, partPath, document1, imageBudget),
|
|
6767
6052
|
charts: await readXlsxWorksheetCharts(archive, partPath, document1),
|
|
6768
|
-
tables: await readXlsxWorksheetTables(archive, partPath)
|
|
6053
|
+
tables: await readXlsxWorksheetTables(archive, partPath),
|
|
6054
|
+
richTextCells: readXlsxRichTextCells(document1, richText)
|
|
6769
6055
|
});
|
|
6770
6056
|
}
|
|
6771
6057
|
return features;
|
|
6772
6058
|
}
|
|
6059
|
+
function xlsxWorksheetMayReferenceSharedStrings(source) {
|
|
6060
|
+
return /<(?:[A-Za-z_][\w.-]*:)?c(?=[\s/>])[^>]*\bt\s*=\s*(?:"s"|'s')/.test(source);
|
|
6061
|
+
}
|
|
6773
6062
|
function emptyXlsxSheetFeatures() {
|
|
6774
6063
|
return {
|
|
6775
6064
|
directCellStyles: [],
|
|
@@ -6784,7 +6073,8 @@ function emptyXlsxSheetFeatures() {
|
|
|
6784
6073
|
},
|
|
6785
6074
|
images: [],
|
|
6786
6075
|
charts: [],
|
|
6787
|
-
tables: []
|
|
6076
|
+
tables: [],
|
|
6077
|
+
richTextCells: []
|
|
6788
6078
|
};
|
|
6789
6079
|
}
|
|
6790
6080
|
async function patchXlsxSheetFeatures(buffer, content) {
|
|
@@ -6797,7 +6087,7 @@ async function patchXlsxSheetFeatures(buffer, content) {
|
|
|
6797
6087
|
pageSetup.sheetId,
|
|
6798
6088
|
pageSetup
|
|
6799
6089
|
]));
|
|
6800
|
-
if (!sheets.some((sheet)=>sheet.frozen || Object.keys(sheet.dataVerification ?? {}).length || sheet.dataValidationRanges?.length || sheet.luckysheet_conditionformat_save?.length || sheetHasDirectCellStyles(sheet) || sheetHasProtectionState(sheet) || Boolean(sheet.id && (pageBreaksBySheetId.get(sheet.id)?.rows?.length ?? 0) + (pageBreaksBySheetId.get(sheet.id)?.columns?.length ?? 0)) || Boolean(sheet.id && pageSetupsBySheetId.has(sheet.id)))) return buffer;
|
|
6090
|
+
if (!sheets.some((sheet)=>sheet.frozen || Object.keys(sheet.dataVerification ?? {}).length || sheet.dataValidationRanges?.length || sheet.luckysheet_conditionformat_save?.length || sheetHasXlsxRichTextCells(sheet) || sheetHasDirectCellStyles(sheet) || sheetHasProtectionState(sheet) || Boolean(sheet.id && (pageBreaksBySheetId.get(sheet.id)?.rows?.length ?? 0) + (pageBreaksBySheetId.get(sheet.id)?.columns?.length ?? 0)) || Boolean(sheet.id && pageSetupsBySheetId.has(sheet.id)))) return buffer;
|
|
6801
6091
|
const archive = await work_ooxml_package_OoxmlPackage.load(buffer);
|
|
6802
6092
|
const worksheetParts = await work_xlsx_interop_readWorksheetParts(archive);
|
|
6803
6093
|
const zip = await jszip.loadAsync(buffer);
|
|
@@ -6810,7 +6100,7 @@ async function patchXlsxSheetFeatures(buffer, content) {
|
|
|
6810
6100
|
for (const sheet of sheets){
|
|
6811
6101
|
const pageBreaks = sheet.id ? pageBreaksBySheetId.get(sheet.id) : void 0;
|
|
6812
6102
|
const pageSetup = sheet.id ? pageSetupsBySheetId.get(sheet.id) : void 0;
|
|
6813
|
-
if (!sheet.frozen && !Object.keys(sheet.dataVerification ?? {}).length && !sheet.dataValidationRanges?.length && !sheet.luckysheet_conditionformat_save?.length && !sheetHasDirectCellStyles(sheet) && !sheetHasProtectionState(sheet) && !(pageBreaks?.rows?.length || pageBreaks?.columns?.length) && !pageSetup) continue;
|
|
6103
|
+
if (!sheet.frozen && !Object.keys(sheet.dataVerification ?? {}).length && !sheet.dataValidationRanges?.length && !sheet.luckysheet_conditionformat_save?.length && !sheetHasXlsxRichTextCells(sheet) && !sheetHasDirectCellStyles(sheet) && !sheetHasProtectionState(sheet) && !(pageBreaks?.rows?.length || pageBreaks?.columns?.length) && !pageSetup) continue;
|
|
6814
6104
|
const exportedName = sheet.name.slice(0, 31) || '工作表';
|
|
6815
6105
|
const partPath = worksheetParts.get(exportedName);
|
|
6816
6106
|
const entry = partPath ? zip.file(partPath) : null;
|
|
@@ -6820,6 +6110,7 @@ async function patchXlsxSheetFeatures(buffer, content) {
|
|
|
6820
6110
|
writeDataValidations(document1, sheet.dataVerification, sheet.dataValidationRanges, new Set((content.namedRanges ?? []).filter((namedRange)=>!namedRange.scopeSheetId || namedRange.scopeSheetId === sheet.id).map((namedRange)=>namedRange.name.trim().toLocaleLowerCase())));
|
|
6821
6111
|
writeXlsxConditionalFormats(document1, sheet.luckysheet_conditionformat_save, differentialFormats);
|
|
6822
6112
|
if (directCellStyles) writeXlsxDirectCellStyles(document1, sheet, directCellStyles);
|
|
6113
|
+
writeXlsxRichTextCells(document1, sheet, semanticPalette?.palette);
|
|
6823
6114
|
writeXlsxProtection(document1, sheet, cellProtection);
|
|
6824
6115
|
writeXlsxPageSetup(document1, pageSetup);
|
|
6825
6116
|
writeXlsxManualPageBreaks(document1, pageBreaks);
|
|
@@ -6834,9 +6125,12 @@ async function patchXlsxSheetFeatures(buffer, content) {
|
|
|
6834
6125
|
}
|
|
6835
6126
|
function spreadsheetXlsxStyleOrigins(content) {
|
|
6836
6127
|
const origins = [];
|
|
6837
|
-
for (const sheet of content.sheets)
|
|
6838
|
-
const
|
|
6839
|
-
|
|
6128
|
+
for (const sheet of content.sheets){
|
|
6129
|
+
for (const [, row] of sparseArrayEntries(sheet.data))for (const [, cell] of sparseArrayEntries(row)){
|
|
6130
|
+
const origin = xlsxCellStyleOrigin(cell);
|
|
6131
|
+
if (origin) origins.push(origin);
|
|
6132
|
+
}
|
|
6133
|
+
origins.push(...xlsxRichTextStyleOrigins(sheet));
|
|
6840
6134
|
}
|
|
6841
6135
|
return origins;
|
|
6842
6136
|
}
|
|
@@ -8045,7 +7339,7 @@ function createSparseXlsxWorksheet(sheet, XLSX) {
|
|
|
8045
7339
|
function xlsxCellObject(cell, row, column, sheet) {
|
|
8046
7340
|
if (cell.f) return createXlsxFormulaCell(cell, row, column, sheet);
|
|
8047
7341
|
if (cell.ct?.t === 'e') return createXlsxErrorCell(cell);
|
|
8048
|
-
const value = cell.v ?? cell.m;
|
|
7342
|
+
const value = xlsxRichTextCellText(cell) ?? cell.v ?? cell.m;
|
|
8049
7343
|
if (null == value) return cell.ps ? {
|
|
8050
7344
|
t: 's',
|
|
8051
7345
|
v: ''
|
|
@@ -8723,6 +8017,10 @@ async function importWorkSpreadsheetFile(file, extension, context) {
|
|
|
8723
8017
|
spreadsheetCellKey(entry.row, entry.column),
|
|
8724
8018
|
entry
|
|
8725
8019
|
]));
|
|
8020
|
+
const richTextCells = new Map((features?.richTextCells ?? []).map((entry)=>[
|
|
8021
|
+
spreadsheetCellKey(entry.row, entry.column),
|
|
8022
|
+
entry
|
|
8023
|
+
]));
|
|
8726
8024
|
const range = safeSpreadsheetRange(worksheet, XLSX);
|
|
8727
8025
|
let rowCount = Math.max(plainWorksheet?.rowCount ?? range.e.r + 1, 40);
|
|
8728
8026
|
let columnCount = Math.max(plainWorksheet?.columnCount ?? range.e.c + 1, 12);
|
|
@@ -8752,7 +8050,7 @@ async function importWorkSpreadsheetFile(file, extension, context) {
|
|
|
8752
8050
|
const directCellStyle = directCellStyles.get(spreadsheetCellKey(row, column));
|
|
8753
8051
|
directCellStyles.delete(spreadsheetCellKey(row, column));
|
|
8754
8052
|
data[row] ??= [];
|
|
8755
|
-
data[row][column] = freezeImportedSpreadsheetCell(withXlsxCellStyleOrigin(fortuneCellFromXlsx(source, row, column, id, hyperlink, comment, XLSX, directCellStyle?.style), directCellStyle?.origin));
|
|
8053
|
+
data[row][column] = freezeImportedSpreadsheetCell(withXlsxCellStyleOrigin(applyImportedXlsxRichText(fortuneCellFromXlsx(source, row, column, id, hyperlink, comment, XLSX, directCellStyle?.style), richTextCells.get(spreadsheetCellKey(row, column))), directCellStyle?.origin));
|
|
8756
8054
|
if (source.f) formulaCells.push({
|
|
8757
8055
|
column,
|
|
8758
8056
|
row
|
|
@@ -9896,4 +9194,4 @@ function nextPaint() {
|
|
|
9896
9194
|
function work_pdf_export_safeFileName(value) {
|
|
9897
9195
|
return value.replace(/[<>:"/\\|?*\u0000-\u001f]/g, '_').trim() || 'A3S Work file';
|
|
9898
9196
|
}
|
|
9899
|
-
export { MAX_XLSX_WORKSHEET_IMAGE_BYTES, WORK_DOCUMENT_SNAPSHOT_MEDIA_TYPE as DOCUMENT_SNAPSHOT_MEDIA_TYPE, WORK_DOCUMENT_SNAPSHOT_SCHEMA as DOCUMENT_SNAPSHOT_SCHEMA, WORK_DOCUMENT_SNAPSHOT_VERSION as DOCUMENT_SNAPSHOT_VERSION, WORK_DOCUMENT_SOURCE_MEDIA_TYPE as DOCUMENT_SOURCE_MEDIA_TYPE, WORK_DOCUMENT_SOURCE_SCHEMA as DOCUMENT_SOURCE_SCHEMA, WORK_DOCUMENT_SOURCE_VERSION as DOCUMENT_SOURCE_VERSION, WORK_IMPORT_ACCEPT as OFFICE_FILE_ACCEPT, WORK_OFFICE_COLLABORATION_DEFAULT_MAX_TRANSPORT_PAYLOAD_BYTES as OFFICE_COLLABORATION_DEFAULT_MAX_TRANSPORT_PAYLOAD_BYTES, WORK_OFFICE_COLLABORATION_MAX_TRANSPORT_PAYLOAD_BYTES as OFFICE_COLLABORATION_MAX_TRANSPORT_PAYLOAD_BYTES, WORK_OFFICE_COLLABORATION_PRESENCE_FIELD as OFFICE_COLLABORATION_PRESENCE_FIELD, applyWorkDocumentSource as applyDocumentSource, createWorkArtifactBlob as createArtifactBlob, createWorkOfficeCollaborationPresence as createOfficeCollaborationPresence, createWorkOfficeCollaborationTransportBinding as createOfficeCollaborationTransportBinding, createWorkPdfCollaborationContent as createPdfCollaborationContent, decodeWorkDocumentSnapshot as decodeDocumentSnapshot, defaultPptxRuntimeUrl, diagnoseXlsxProtection, emptySpreadsheetWorksheetCompatibilitySummary, encodeWorkDocumentSnapshot as encodeDocumentSnapshot, exportWorkArtifact as downloadArtifact, exportWorkArtifactPdf as downloadArtifactPdf, forgetWorkSourceBlob as forgetSourceBlob, importWorkFile as importOfficeFile, inspectXlsxHeaderFooterText, inspectXlsxPivotTables, isEditableXlsxPaperSizeCode, isSupportedXlsxChartLegend, isSupportedXlsxChartPlotLayout, isSupportedXlsxChartSeriesFormatting, isSupportedXlsxCombinationChartNodes, isSupportedXlsxWorksheetImageContentType, parseXlsxChartAxes, parseXlsxChartLegend, parseXlsxChartPlotLayout, parseXlsxChartSeriesStyle, parseXlsxErrorBars, parseXlsxTrendline, projectWorkDocumentSource as projectDocumentSource, readWorkSourceBlob as readSourceBlob, readXlsxFormulaFeaturesFromPackage, rememberWorkSourceBlob as registerSourceBlob, updateSpreadsheetWorksheetCompatibilitySummary, workArtifactExtension as artifactExtension, workArtifactKindLabel as artifactKindLabel, workKindForFile as officeKindForFile, workPdfPagesForExport as pdfPagesForExport, xlsxChartNodeUsesStackedGrouping, xlsxChartSeriesFormattingShapeProperties, xlsxChartSeriesMarkerXml, xlsxChartSeriesShapePropertiesXml
|
|
9197
|
+
export { MAX_XLSX_WORKSHEET_IMAGE_BYTES, WORK_DOCUMENT_SNAPSHOT_MEDIA_TYPE as DOCUMENT_SNAPSHOT_MEDIA_TYPE, WORK_DOCUMENT_SNAPSHOT_SCHEMA as DOCUMENT_SNAPSHOT_SCHEMA, WORK_DOCUMENT_SNAPSHOT_VERSION as DOCUMENT_SNAPSHOT_VERSION, WORK_DOCUMENT_SOURCE_MEDIA_TYPE as DOCUMENT_SOURCE_MEDIA_TYPE, WORK_DOCUMENT_SOURCE_SCHEMA as DOCUMENT_SOURCE_SCHEMA, WORK_DOCUMENT_SOURCE_VERSION as DOCUMENT_SOURCE_VERSION, WORK_IMPORT_ACCEPT as OFFICE_FILE_ACCEPT, WORK_OFFICE_COLLABORATION_DEFAULT_MAX_TRANSPORT_PAYLOAD_BYTES as OFFICE_COLLABORATION_DEFAULT_MAX_TRANSPORT_PAYLOAD_BYTES, WORK_OFFICE_COLLABORATION_MAX_TRANSPORT_PAYLOAD_BYTES as OFFICE_COLLABORATION_MAX_TRANSPORT_PAYLOAD_BYTES, WORK_OFFICE_COLLABORATION_PRESENCE_FIELD as OFFICE_COLLABORATION_PRESENCE_FIELD, applyWorkDocumentSource as applyDocumentSource, createWorkArtifactBlob as createArtifactBlob, createWorkOfficeCollaborationPresence as createOfficeCollaborationPresence, createWorkOfficeCollaborationTransportBinding as createOfficeCollaborationTransportBinding, createWorkPdfCollaborationContent as createPdfCollaborationContent, decodeWorkDocumentSnapshot as decodeDocumentSnapshot, defaultPptxRuntimeUrl, diagnoseXlsxProtection, emptySpreadsheetWorksheetCompatibilitySummary, encodeWorkDocumentSnapshot as encodeDocumentSnapshot, exportWorkArtifact as downloadArtifact, exportWorkArtifactPdf as downloadArtifactPdf, forgetWorkSourceBlob as forgetSourceBlob, importWorkFile as importOfficeFile, inspectXlsxHeaderFooterText, inspectXlsxPivotTables, isEditableXlsxPaperSizeCode, isSupportedXlsxChartLegend, isSupportedXlsxChartPlotLayout, isSupportedXlsxChartSeriesFormatting, isSupportedXlsxCombinationChartNodes, isSupportedXlsxWorksheetImageContentType, parseXlsxChartAxes, parseXlsxChartLegend, parseXlsxChartPlotLayout, parseXlsxChartSeriesStyle, parseXlsxErrorBars, parseXlsxTrendline, projectWorkDocumentSource as projectDocumentSource, readWorkSourceBlob as readSourceBlob, readXlsxFormulaFeaturesFromPackage, rememberWorkSourceBlob as registerSourceBlob, updateSpreadsheetWorksheetCompatibilitySummary, workArtifactExtension as artifactExtension, workArtifactKindLabel as artifactKindLabel, workKindForFile as officeKindForFile, workPdfPagesForExport as pdfPagesForExport, xlsxChartNodeUsesStackedGrouping, xlsxChartSeriesFormattingShapeProperties, xlsxChartSeriesMarkerXml, xlsxChartSeriesShapePropertiesXml };
|