@a3s-lab/office 0.36.0 → 0.37.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 +13 -6
- package/dist/0~7048.js +93 -1
- package/dist/0~spreadsheet-editor.js +388 -35
- package/dist/3266.js +366 -6
- package/dist/4121.js +1942 -1939
- package/dist/core.js +30 -3
- package/dist/internal/features/work/editors/spreadsheet-table-totals.d.ts +39 -0
- package/dist/internal/features/work/editors/spreadsheet-table.d.ts +11 -1
- package/dist/internal/features/work/work-types.d.ts +14 -0
- package/dist/internal/kernel/office-kernel-spreadsheet-fallback-formula.d.ts +11 -0
- package/dist/office-kernel.wasm +0 -0
- package/dist/office-kernel.worker.js +93 -1
- package/dist/styles.css +120 -0
- package/docs/latest/en/browser-editor-architecture.md +8 -2
- package/package.json +4 -1
package/dist/3266.js
CHANGED
|
@@ -173,6 +173,340 @@ function nearestSpreadsheetTableCell(sheet, table, row, column) {
|
|
|
173
173
|
}
|
|
174
174
|
return null;
|
|
175
175
|
}
|
|
176
|
+
const MAX_SPREADSHEET_TABLE_TOTALS_FORMULA_LENGTH = 8192;
|
|
177
|
+
const MAX_SPREADSHEET_TABLE_TOTALS_LABEL_LENGTH = 255;
|
|
178
|
+
const DEFAULT_SPREADSHEET_TABLE_TOTALS_LABEL = 'Total';
|
|
179
|
+
const SPREADSHEET_TABLE_TOTALS_FUNCTIONS = Object.freeze([
|
|
180
|
+
'sum',
|
|
181
|
+
'average',
|
|
182
|
+
'count',
|
|
183
|
+
'countNums',
|
|
184
|
+
'max',
|
|
185
|
+
'min',
|
|
186
|
+
'stdDev',
|
|
187
|
+
'stdDevP',
|
|
188
|
+
'var',
|
|
189
|
+
'varP',
|
|
190
|
+
'custom'
|
|
191
|
+
]);
|
|
192
|
+
const UNSAFE_TOTALS_FUNCTIONS = new Set([
|
|
193
|
+
'CALL',
|
|
194
|
+
'DDE',
|
|
195
|
+
'DDE.REQUEST',
|
|
196
|
+
'DDE.POKE',
|
|
197
|
+
'EXEC',
|
|
198
|
+
'HYPERLINK',
|
|
199
|
+
'INDIRECT',
|
|
200
|
+
'OFFSET',
|
|
201
|
+
'REGISTER.ID',
|
|
202
|
+
'RTD',
|
|
203
|
+
'WEBSERVICE'
|
|
204
|
+
]);
|
|
205
|
+
const SUBTOTAL_CODES = {
|
|
206
|
+
average: 101,
|
|
207
|
+
count: 103,
|
|
208
|
+
countNums: 102,
|
|
209
|
+
max: 104,
|
|
210
|
+
min: 105,
|
|
211
|
+
stdDev: 107,
|
|
212
|
+
stdDevP: 108,
|
|
213
|
+
sum: 109,
|
|
214
|
+
var: 110,
|
|
215
|
+
varP: 111
|
|
216
|
+
};
|
|
217
|
+
const OOXML_TOTALS_FUNCTIONS = {
|
|
218
|
+
average: 'average',
|
|
219
|
+
count: 'count',
|
|
220
|
+
countNums: 'countNums',
|
|
221
|
+
max: 'max',
|
|
222
|
+
min: 'min',
|
|
223
|
+
stdDev: 'stdDev',
|
|
224
|
+
stdDevP: 'stdDevp',
|
|
225
|
+
sum: 'sum',
|
|
226
|
+
var: 'var',
|
|
227
|
+
varP: 'varp'
|
|
228
|
+
};
|
|
229
|
+
const TOTALS_FUNCTION_LABELS = {
|
|
230
|
+
sum: '求和',
|
|
231
|
+
average: '平均值',
|
|
232
|
+
count: '计数',
|
|
233
|
+
countNums: '数值计数',
|
|
234
|
+
max: '最大值',
|
|
235
|
+
min: '最小值',
|
|
236
|
+
stdDev: '标准差',
|
|
237
|
+
stdDevP: '总体标准差',
|
|
238
|
+
var: '方差',
|
|
239
|
+
varP: '总体方差',
|
|
240
|
+
custom: '自定义'
|
|
241
|
+
};
|
|
242
|
+
function spreadsheetTableTotalsFunctionLabel(value) {
|
|
243
|
+
return value ? TOTALS_FUNCTION_LABELS[value] : '不汇总';
|
|
244
|
+
}
|
|
245
|
+
function normalizeSpreadsheetTableTotalsFunction(value) {
|
|
246
|
+
if ('string' != typeof value) return;
|
|
247
|
+
if ('none' === value || '' === value) return;
|
|
248
|
+
return SPREADSHEET_TABLE_TOTALS_FUNCTIONS.includes(value) ? value : void 0;
|
|
249
|
+
}
|
|
250
|
+
function normalizeSpreadsheetTableTotalsFormula(value) {
|
|
251
|
+
if ('string' != typeof value) return;
|
|
252
|
+
const trimmed = value.trim();
|
|
253
|
+
if (!trimmed) return;
|
|
254
|
+
const formula = trimmed.startsWith('=') ? trimmed : `=${trimmed}`;
|
|
255
|
+
if (formula.startsWith('==') || formula.length > MAX_SPREADSHEET_TABLE_TOTALS_FORMULA_LENGTH || /[\u0000-\u001f\u007f]/u.test(formula) || formulaHasExternalReference(formula) || spreadsheetFormulaFunctions(formula).some((name)=>UNSAFE_TOTALS_FUNCTIONS.has(name))) return;
|
|
256
|
+
const editable = editableSpreadsheetFormula(formula).trim();
|
|
257
|
+
return editable || void 0;
|
|
258
|
+
}
|
|
259
|
+
function normalizeSpreadsheetTableTotalsLabel(value) {
|
|
260
|
+
if ('string' != typeof value) return;
|
|
261
|
+
const label = value.trim();
|
|
262
|
+
if (!label || Array.from(label).length > MAX_SPREADSHEET_TABLE_TOTALS_LABEL_LENGTH || /[\u0000-\u001f\u007f]/u.test(label)) return;
|
|
263
|
+
return label;
|
|
264
|
+
}
|
|
265
|
+
function spreadsheetTableTotalsFunctionFromOoxml(value) {
|
|
266
|
+
if ('string' != typeof value) return;
|
|
267
|
+
const normalized = value.trim().toLowerCase();
|
|
268
|
+
if ('custom' === normalized) return 'custom';
|
|
269
|
+
const entry = Object.entries(OOXML_TOTALS_FUNCTIONS).find(([, token])=>token.toLowerCase() === normalized);
|
|
270
|
+
return entry?.[0];
|
|
271
|
+
}
|
|
272
|
+
function spreadsheetTableTotalsFunctionToOoxml(value) {
|
|
273
|
+
if (!value || 'custom' === value) return 'custom' === value ? 'custom' : void 0;
|
|
274
|
+
return OOXML_TOTALS_FUNCTIONS[value];
|
|
275
|
+
}
|
|
276
|
+
function spreadsheetTableTotalsFormula(table, columnOffset) {
|
|
277
|
+
const column = table.columns[columnOffset];
|
|
278
|
+
if (!column) return;
|
|
279
|
+
const custom = normalizeSpreadsheetTableTotalsFormula(column.totalsFormula);
|
|
280
|
+
if (custom) return custom;
|
|
281
|
+
const functionName = normalizeSpreadsheetTableTotalsFunction(column.totalsFunction);
|
|
282
|
+
if (!functionName || 'custom' === functionName) return;
|
|
283
|
+
const code = SUBTOTAL_CODES[functionName];
|
|
284
|
+
if (!code) return;
|
|
285
|
+
return `=SUBTOTAL(${code},${table.name}[${escapeStructuredColumnName(column.name)}])`;
|
|
286
|
+
}
|
|
287
|
+
function spreadsheetTableTotalsColumnPatch(columns, patches) {
|
|
288
|
+
if (void 0 === patches) return columns.map((column)=>({
|
|
289
|
+
...column
|
|
290
|
+
}));
|
|
291
|
+
const entries = Array.isArray(patches) ? patches.flatMap((patch, offset)=>patch ? [
|
|
292
|
+
[
|
|
293
|
+
String(offset),
|
|
294
|
+
patch
|
|
295
|
+
]
|
|
296
|
+
] : []) : Object.entries(patches);
|
|
297
|
+
const next = columns.map((column)=>({
|
|
298
|
+
...column
|
|
299
|
+
}));
|
|
300
|
+
for (const [rawOffset, patch] of entries){
|
|
301
|
+
const offset = Number(rawOffset);
|
|
302
|
+
if (!Number.isSafeInteger(offset) || offset < 0 || offset >= next.length || !patch || 'object' != typeof patch || Array.isArray(patch)) return null;
|
|
303
|
+
const current = next[offset];
|
|
304
|
+
if (!current) return null;
|
|
305
|
+
const candidate = {
|
|
306
|
+
...current
|
|
307
|
+
};
|
|
308
|
+
if (Object.hasOwn(patch, 'totalsFunction')) if (null === patch.totalsFunction || '' === patch.totalsFunction) delete candidate.totalsFunction;
|
|
309
|
+
else {
|
|
310
|
+
const functionName = normalizeSpreadsheetTableTotalsFunction(patch.totalsFunction);
|
|
311
|
+
if (!functionName) return null;
|
|
312
|
+
candidate.totalsFunction = functionName;
|
|
313
|
+
}
|
|
314
|
+
if (Object.hasOwn(patch, 'totalsLabel')) if (null === patch.totalsLabel || '' === patch.totalsLabel) delete candidate.totalsLabel;
|
|
315
|
+
else {
|
|
316
|
+
const label = normalizeSpreadsheetTableTotalsLabel(patch.totalsLabel);
|
|
317
|
+
if (!label) return null;
|
|
318
|
+
candidate.totalsLabel = label;
|
|
319
|
+
}
|
|
320
|
+
if (Object.hasOwn(patch, 'totalsFormula')) if (null === patch.totalsFormula || '' === patch.totalsFormula) delete candidate.totalsFormula;
|
|
321
|
+
else {
|
|
322
|
+
const formula = normalizeSpreadsheetTableTotalsFormula(patch.totalsFormula);
|
|
323
|
+
if (!formula) return null;
|
|
324
|
+
candidate.totalsFormula = formula;
|
|
325
|
+
}
|
|
326
|
+
if (candidate.totalsFormula) {
|
|
327
|
+
if (void 0 !== candidate.totalsFunction && 'custom' !== candidate.totalsFunction) return null;
|
|
328
|
+
candidate.totalsFunction = 'custom';
|
|
329
|
+
} else if ('custom' === candidate.totalsFunction) return null;
|
|
330
|
+
if (void 0 !== candidate.totalsFunction && 'custom' !== candidate.totalsFunction) delete candidate.totalsFormula;
|
|
331
|
+
if (void 0 !== candidate.totalsFunction && candidate.totalsLabel) delete candidate.totalsLabel;
|
|
332
|
+
next[offset] = candidate;
|
|
333
|
+
}
|
|
334
|
+
return next;
|
|
335
|
+
}
|
|
336
|
+
function withDefaultSpreadsheetTableTotalsLabel(columns, totalsRow) {
|
|
337
|
+
const next = columns.map((column)=>({
|
|
338
|
+
...column
|
|
339
|
+
}));
|
|
340
|
+
if (!totalsRow || !next.length) return next;
|
|
341
|
+
const hasExplicitLabel = next.some((column)=>column.totalsLabel);
|
|
342
|
+
if (hasExplicitLabel) return next;
|
|
343
|
+
const first = next[0];
|
|
344
|
+
if (first && !first.totalsFunction && !first.totalsFormula) first.totalsLabel = DEFAULT_SPREADSHEET_TABLE_TOTALS_LABEL;
|
|
345
|
+
return next;
|
|
346
|
+
}
|
|
347
|
+
function spreadsheetTableTotalsRowHasContent(sheet, table, row = table.totalsRow ? table.range.row[1] : table.range.row[1] + 1) {
|
|
348
|
+
for(let column = table.range.column[0]; column <= table.range.column[1]; column += 1)if (!spreadsheetTableTotalsCellIsEmpty(spreadsheetTableTotalsCellAt(sheet, row, column))) return true;
|
|
349
|
+
return false;
|
|
350
|
+
}
|
|
351
|
+
function synchronizeSpreadsheetTableTotalsRow(sheet, previousTable, nextTable, options = {}) {
|
|
352
|
+
if (!nextTable.totalsRow) return sheet;
|
|
353
|
+
const force = true === options.force;
|
|
354
|
+
const previousRow = previousTable?.range.row[1];
|
|
355
|
+
const nextRow = nextTable.range.row[1];
|
|
356
|
+
const width = nextTable.range.column[1] - nextTable.range.column[0] + 1;
|
|
357
|
+
const updates = new Map();
|
|
358
|
+
for(let offset = 0; offset < width; offset += 1){
|
|
359
|
+
const column = nextTable.range.column[0] + offset;
|
|
360
|
+
const nextColumn = nextTable.columns[offset];
|
|
361
|
+
if (!nextColumn) continue;
|
|
362
|
+
const previousColumn = previousTable?.columns[offset];
|
|
363
|
+
const oldFormula = previousTable ? spreadsheetTableTotalsFormula(previousTable, offset) : void 0;
|
|
364
|
+
const newFormula = spreadsheetTableTotalsFormula(nextTable, offset);
|
|
365
|
+
const oldLabel = normalizeSpreadsheetTableTotalsLabel(previousColumn?.totalsLabel);
|
|
366
|
+
const newLabel = normalizeSpreadsheetTableTotalsLabel(nextColumn.totalsLabel);
|
|
367
|
+
const changed = force || void 0 === previousTable || previousTable.name !== nextTable.name || previousTable.range.row[1] !== nextTable.range.row[1] || previousColumn?.totalsFunction !== nextColumn.totalsFunction || previousColumn?.totalsFormula !== nextColumn.totalsFormula || previousColumn?.totalsLabel !== nextColumn.totalsLabel || previousColumn?.name !== nextColumn.name;
|
|
368
|
+
const current = spreadsheetTableTotalsCellAt(sheet, nextRow, column);
|
|
369
|
+
const previousCell = void 0 === previousRow ? null : spreadsheetTableTotalsCellAt(sheet, previousRow, column);
|
|
370
|
+
const styleSource = current ?? previousCell;
|
|
371
|
+
const empty = spreadsheetTableTotalsCellIsEmpty(current);
|
|
372
|
+
const currentFormula = normalizeSpreadsheetTableTotalsFormula(current?.f);
|
|
373
|
+
const generatedFormula = Boolean(oldFormula && currentFormula && formulasEqual(currentFormula, oldFormula));
|
|
374
|
+
const generatedLabel = Boolean(oldLabel && !current?.f && spreadsheetTableCellText(current) === oldLabel);
|
|
375
|
+
const replaceable = force || empty || changed && (generatedFormula || generatedLabel);
|
|
376
|
+
if (newFormula && replaceable) updates.set(column, spreadsheetCellWithTotalsFormula(styleSource, newFormula));
|
|
377
|
+
else if (newLabel && replaceable) updates.set(column, spreadsheetCellWithTotalsLabel(styleSource, newLabel));
|
|
378
|
+
else if (!newFormula && !newLabel && changed && (generatedFormula || generatedLabel)) updates.set(column, clearSpreadsheetTableTotalsCell(current));
|
|
379
|
+
}
|
|
380
|
+
return applySpreadsheetTableTotalsCellUpdates(sheet, nextRow, updates);
|
|
381
|
+
}
|
|
382
|
+
function reconcileSpreadsheetTableTotalsColumns(sheet, table, editedOffsets) {
|
|
383
|
+
return table.columns.map((column, offset)=>{
|
|
384
|
+
const candidate = {
|
|
385
|
+
...column
|
|
386
|
+
};
|
|
387
|
+
const declaredFunction = normalizeSpreadsheetTableTotalsFunction(candidate.totalsFunction);
|
|
388
|
+
const declaredFormula = normalizeSpreadsheetTableTotalsFormula(candidate.totalsFormula);
|
|
389
|
+
if (declaredFunction) candidate.totalsFunction = declaredFunction;
|
|
390
|
+
else delete candidate.totalsFunction;
|
|
391
|
+
if (declaredFormula) candidate.totalsFormula = declaredFormula;
|
|
392
|
+
else delete candidate.totalsFormula;
|
|
393
|
+
const label = normalizeSpreadsheetTableTotalsLabel(candidate.totalsLabel);
|
|
394
|
+
if (label) candidate.totalsLabel = label;
|
|
395
|
+
else delete candidate.totalsLabel;
|
|
396
|
+
if (!table.totalsRow) return candidate;
|
|
397
|
+
const cell = spreadsheetTableTotalsCellAt(sheet, table.range.row[1], table.range.column[0] + offset);
|
|
398
|
+
if (editedOffsets && !editedOffsets.has(offset)) return candidate;
|
|
399
|
+
const cellFormula = normalizeSpreadsheetTableTotalsFormula(cell?.f);
|
|
400
|
+
const expected = spreadsheetTableTotalsFormula({
|
|
401
|
+
...table,
|
|
402
|
+
columns: [
|
|
403
|
+
{
|
|
404
|
+
...candidate
|
|
405
|
+
}
|
|
406
|
+
]
|
|
407
|
+
}, 0);
|
|
408
|
+
if (cellFormula) {
|
|
409
|
+
if (expected && formulasEqual(cellFormula, expected)) return candidate;
|
|
410
|
+
delete candidate.totalsFunction;
|
|
411
|
+
delete candidate.totalsFormula;
|
|
412
|
+
candidate.totalsFunction = 'custom';
|
|
413
|
+
candidate.totalsFormula = cellFormula;
|
|
414
|
+
return candidate;
|
|
415
|
+
}
|
|
416
|
+
delete candidate.totalsFunction;
|
|
417
|
+
delete candidate.totalsFormula;
|
|
418
|
+
const cellLabel = normalizeSpreadsheetTableTotalsLabel(spreadsheetTableCellText(cell));
|
|
419
|
+
if (cellLabel) if (candidate.totalsLabel && candidate.totalsLabel !== cellLabel) delete candidate.totalsLabel;
|
|
420
|
+
else candidate.totalsLabel = cellLabel;
|
|
421
|
+
else delete candidate.totalsLabel;
|
|
422
|
+
return candidate;
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
function escapeStructuredColumnName(value) {
|
|
426
|
+
return value.replaceAll(']', ']]');
|
|
427
|
+
}
|
|
428
|
+
function formulasEqual(left, right) {
|
|
429
|
+
return left.trim().replace(/\s+/g, '').toLocaleLowerCase() === right.trim().replace(/\s+/g, '').toLocaleLowerCase();
|
|
430
|
+
}
|
|
431
|
+
function spreadsheetTableTotalsCellAt(sheet, row, column) {
|
|
432
|
+
return sheet.data?.[row]?.[column] ?? sheet.celldata?.find((entry)=>entry.r === row && entry.c === column)?.v ?? null;
|
|
433
|
+
}
|
|
434
|
+
function spreadsheetTableTotalsCellIsEmpty(cell) {
|
|
435
|
+
return !cell?.f && (cell?.v === void 0 || null === cell.v || '' === cell.v) && (cell?.m === void 0 || null === cell.m || '' === cell.m);
|
|
436
|
+
}
|
|
437
|
+
function spreadsheetTableCellText(cell) {
|
|
438
|
+
const value = cell?.m ?? cell?.v;
|
|
439
|
+
return null == value ? '' : String(value);
|
|
440
|
+
}
|
|
441
|
+
function spreadsheetCellWithTotalsFormula(source, formula) {
|
|
442
|
+
const { f: _formula, m: _display, v: _value, ...presentation } = source ?? {};
|
|
443
|
+
return {
|
|
444
|
+
...presentation,
|
|
445
|
+
f: formula
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
function spreadsheetCellWithTotalsLabel(source, label) {
|
|
449
|
+
const { f: _formula, ...withoutFormula } = source ?? {};
|
|
450
|
+
return {
|
|
451
|
+
...withoutFormula,
|
|
452
|
+
m: label,
|
|
453
|
+
v: label
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
function clearSpreadsheetTableTotalsCell(source) {
|
|
457
|
+
if (!source) return null;
|
|
458
|
+
const { f: _formula, m: _display, v: _value, ...presentation } = source;
|
|
459
|
+
return Object.keys(presentation).length ? presentation : null;
|
|
460
|
+
}
|
|
461
|
+
function applySpreadsheetTableTotalsCellUpdates(sheet, rowIndex, updates) {
|
|
462
|
+
if (!updates.size) return sheet;
|
|
463
|
+
if (void 0 !== sheet.data) {
|
|
464
|
+
const data = sheet.data.slice();
|
|
465
|
+
const source = data[rowIndex];
|
|
466
|
+
const row = source ? source.slice() : [];
|
|
467
|
+
for (const [column, cell] of updates)row[column] = cell;
|
|
468
|
+
data[rowIndex] = row;
|
|
469
|
+
return {
|
|
470
|
+
...sheet,
|
|
471
|
+
data
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
const entries = [
|
|
475
|
+
...sheet.celldata ?? []
|
|
476
|
+
];
|
|
477
|
+
const indexes = new Map(entries.map((entry, index)=>[
|
|
478
|
+
`${entry.r}:${entry.c}`,
|
|
479
|
+
index
|
|
480
|
+
]));
|
|
481
|
+
for (const [column, cell] of updates){
|
|
482
|
+
const key = `${rowIndex}:${column}`;
|
|
483
|
+
const index = indexes.get(key);
|
|
484
|
+
if (null === cell) {
|
|
485
|
+
if (void 0 !== index) entries.splice(index, 1);
|
|
486
|
+
if (void 0 !== index) {
|
|
487
|
+
indexes.clear();
|
|
488
|
+
entries.forEach((entry, nextIndex)=>{
|
|
489
|
+
indexes.set(`${entry.r}:${entry.c}`, nextIndex);
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
continue;
|
|
493
|
+
}
|
|
494
|
+
const entry = {
|
|
495
|
+
r: rowIndex,
|
|
496
|
+
c: column,
|
|
497
|
+
v: cell
|
|
498
|
+
};
|
|
499
|
+
if (void 0 === index) {
|
|
500
|
+
indexes.set(key, entries.length);
|
|
501
|
+
entries.push(entry);
|
|
502
|
+
} else entries[index] = entry;
|
|
503
|
+
}
|
|
504
|
+
entries.sort((left, right)=>left.r - right.r || left.c - right.c);
|
|
505
|
+
return {
|
|
506
|
+
...sheet,
|
|
507
|
+
celldata: entries
|
|
508
|
+
};
|
|
509
|
+
}
|
|
176
510
|
function requiredCoordinate(value, maximum, label, sheetId) {
|
|
177
511
|
if (!Number.isSafeInteger(value) || value < 0 || value >= maximum) invalidWorkOfficeSpreadsheetInput(`a valid ${label} coordinate in sheet '${sheetId}'`);
|
|
178
512
|
return value;
|
|
@@ -428,20 +762,46 @@ function requiredSpreadsheetTableColumns(value, width, label) {
|
|
|
428
762
|
const record = requiredInputRecord(candidate, `${label} column`);
|
|
429
763
|
assertOptionalRecordKeys(record, [
|
|
430
764
|
'name',
|
|
431
|
-
'calculatedFormula'
|
|
765
|
+
'calculatedFormula',
|
|
766
|
+
'totalsFunction',
|
|
767
|
+
'totalsLabel',
|
|
768
|
+
'totalsFormula'
|
|
432
769
|
], `column for ${label}`);
|
|
433
770
|
const name = requiredTableColumnName(record.name, label);
|
|
434
771
|
const normalized = name.toLocaleLowerCase();
|
|
435
772
|
if (names.has(normalized)) invalidWorkOfficeSpreadsheetInput(`unique column names for ${label}`);
|
|
436
773
|
names.add(normalized);
|
|
437
|
-
|
|
774
|
+
let calculatedFormula;
|
|
775
|
+
if (void 0 !== record.calculatedFormula) {
|
|
776
|
+
calculatedFormula = normalizeSpreadsheetTableCalculatedFormula(record.calculatedFormula);
|
|
777
|
+
if (!calculatedFormula || calculatedFormula !== record.calculatedFormula) invalidWorkOfficeSpreadsheetInput(`a bounded structured calculated-column formula for ${label}`);
|
|
778
|
+
}
|
|
779
|
+
const totalsFunction = void 0 === record.totalsFunction ? void 0 : normalizeSpreadsheetTableTotalsFunction(record.totalsFunction);
|
|
780
|
+
if (void 0 !== record.totalsFunction && (!totalsFunction || totalsFunction !== record.totalsFunction)) invalidWorkOfficeSpreadsheetInput(`a supported totals-row function for ${label}`);
|
|
781
|
+
const totalsLabel = void 0 === record.totalsLabel ? void 0 : normalizeSpreadsheetTableTotalsLabel(record.totalsLabel);
|
|
782
|
+
if (void 0 !== record.totalsLabel && (!totalsLabel || totalsLabel !== record.totalsLabel)) invalidWorkOfficeSpreadsheetInput(`a bounded totals-row label for ${label}`);
|
|
783
|
+
const totalsFormula = void 0 === record.totalsFormula ? void 0 : normalizeSpreadsheetTableTotalsFormula(record.totalsFormula);
|
|
784
|
+
if (void 0 !== record.totalsFormula && (!totalsFormula || totalsFormula !== record.totalsFormula)) invalidWorkOfficeSpreadsheetInput(`a bounded totals-row formula for ${label}`);
|
|
785
|
+
if (totalsFormula && 'custom' !== totalsFunction) invalidWorkOfficeSpreadsheetInput(`custom totals-row formulas to declare the custom function for ${label}`);
|
|
786
|
+
if ('custom' === totalsFunction && !totalsFormula) invalidWorkOfficeSpreadsheetInput(`custom totals-row functions to include a formula for ${label}`);
|
|
787
|
+
if ((totalsFunction || totalsFormula) && totalsLabel) invalidWorkOfficeSpreadsheetInput(`totals-row labels not to share a cell with a formula for ${label}`);
|
|
788
|
+
if (!calculatedFormula && !totalsFunction && !totalsLabel && !totalsFormula) return {
|
|
438
789
|
name
|
|
439
790
|
};
|
|
440
|
-
const calculatedFormula = normalizeSpreadsheetTableCalculatedFormula(record.calculatedFormula);
|
|
441
|
-
if (!calculatedFormula || calculatedFormula !== record.calculatedFormula) invalidWorkOfficeSpreadsheetInput(`a bounded structured calculated-column formula for ${label}`);
|
|
442
791
|
return {
|
|
443
792
|
name,
|
|
444
|
-
calculatedFormula
|
|
793
|
+
...calculatedFormula ? {
|
|
794
|
+
calculatedFormula
|
|
795
|
+
} : {},
|
|
796
|
+
...totalsFunction ? {
|
|
797
|
+
totalsFunction
|
|
798
|
+
} : {},
|
|
799
|
+
...totalsLabel ? {
|
|
800
|
+
totalsLabel
|
|
801
|
+
} : {},
|
|
802
|
+
...totalsFormula ? {
|
|
803
|
+
totalsFormula
|
|
804
|
+
} : {}
|
|
445
805
|
};
|
|
446
806
|
});
|
|
447
807
|
}
|
|
@@ -2563,4 +2923,4 @@ function work_xlsx_rich_text_nonNegativeInteger(value) {
|
|
|
2563
2923
|
function work_xlsx_rich_text_isRecord(value) {
|
|
2564
2924
|
return 'object' == typeof value && null !== value && !Array.isArray(value);
|
|
2565
2925
|
}
|
|
2566
|
-
export { activeXlsxNativeFill, activeXlsxSemanticColorOrigin, applyImportedXlsxRichText, boundedSpreadsheetDataValidationText, coalesceXlsxRichTextRuns, createWorkOfficeSpreadsheetCollaborationBinding as createOfficeSpreadsheetCollaborationBinding, createXlsxRichTextReadContext, deleteXlsxNativeFills, directXlsxAlignment, directXlsxFontStyle, fillSpreadsheetTableCalculatedColumns, hasXlsxDirectFontStyle, initializeWorkOfficeSpreadsheetCollaboration as initializeOfficeSpreadsheetCollaboration, isHighSurrogate, isLowSurrogate, isSpreadsheetTextOrientationId, isSpreadsheetUnderlineStyle, normalizeSpreadsheetDataValidationErrorStyle, normalizeSpreadsheetDateValidationBoundary, normalizeSpreadsheetTableCalculatedFormula, normalizeXlsxRichTextCell, normalizeXlsxRichTextColor, normalizeXlsxRichTextEditSource, normalizeXlsxRichTextRun, patchSpreadsheetRichTextFontRuns, readWorkOfficeSpreadsheetCollaboration as readOfficeSpreadsheetCollaboration, readXlsxRichTextCells, reconcileSpreadsheetTableCalculatedColumns, replaceWorkOfficeSpreadsheetCollaboration as replaceOfficeSpreadsheetCollaboration, sameXlsxRichTextRunStyle, sheetHasXlsxRichTextCells, spreadsheetCellValueWithDiagonalBorder, spreadsheetDateValidationFormula, spreadsheetDiagonalBorderFromCellValue, spreadsheetExplicitTextOrientationFromCell, spreadsheetTextOrientationCellStyle, spreadsheetTextOrientationChoiceFromCell, spreadsheetTextOrientationFromAngle, spreadsheetTextOrientationFromCell, spreadsheetTextOrientationFromChoice, spreadsheetTextOrientationFromXlsx, spreadsheetUnderlineCellValue, spreadsheetUnderlineCellValueFromSheetJs, spreadsheetUnderlineCellValueFromXlsx, spreadsheetUnderlineStyle, spreadsheetVisibleTextRotationFromCell, validXlsxRichText, writeXlsxRichTextCells, xlsxAlignmentMatches, xlsxBooleanAttribute, xlsxBorderLineMatches, xlsxColorMatches, xlsxNativeFillCellKeys, xlsxNativeFillKey, xlsxNativeFillSemanticColors, xlsxRichTextCellText, xlsxRichTextStyleOrigins, xlsxStyleCollectionIndex, xlsxToggleEnabled, xlsxUnderlineStyle };
|
|
2926
|
+
export { SPREADSHEET_TABLE_TOTALS_FUNCTIONS, activeXlsxNativeFill, activeXlsxSemanticColorOrigin, applyImportedXlsxRichText, boundedSpreadsheetDataValidationText, coalesceXlsxRichTextRuns, createWorkOfficeSpreadsheetCollaborationBinding as createOfficeSpreadsheetCollaborationBinding, createXlsxRichTextReadContext, deleteXlsxNativeFills, directXlsxAlignment, directXlsxFontStyle, fillSpreadsheetTableCalculatedColumns, hasXlsxDirectFontStyle, initializeWorkOfficeSpreadsheetCollaboration as initializeOfficeSpreadsheetCollaboration, isHighSurrogate, isLowSurrogate, isSpreadsheetTextOrientationId, isSpreadsheetUnderlineStyle, normalizeSpreadsheetDataValidationErrorStyle, normalizeSpreadsheetDateValidationBoundary, normalizeSpreadsheetTableCalculatedFormula, normalizeSpreadsheetTableTotalsFormula, normalizeSpreadsheetTableTotalsLabel, normalizeXlsxRichTextCell, normalizeXlsxRichTextColor, normalizeXlsxRichTextEditSource, normalizeXlsxRichTextRun, patchSpreadsheetRichTextFontRuns, readWorkOfficeSpreadsheetCollaboration as readOfficeSpreadsheetCollaboration, readXlsxRichTextCells, reconcileSpreadsheetTableCalculatedColumns, reconcileSpreadsheetTableTotalsColumns, replaceWorkOfficeSpreadsheetCollaboration as replaceOfficeSpreadsheetCollaboration, sameXlsxRichTextRunStyle, sheetHasXlsxRichTextCells, spreadsheetCellValueWithDiagonalBorder, spreadsheetDateValidationFormula, spreadsheetDiagonalBorderFromCellValue, spreadsheetExplicitTextOrientationFromCell, spreadsheetTableTotalsColumnPatch, spreadsheetTableTotalsFunctionFromOoxml, spreadsheetTableTotalsFunctionLabel, spreadsheetTableTotalsFunctionToOoxml, spreadsheetTableTotalsRowHasContent, spreadsheetTextOrientationCellStyle, spreadsheetTextOrientationChoiceFromCell, spreadsheetTextOrientationFromAngle, spreadsheetTextOrientationFromCell, spreadsheetTextOrientationFromChoice, spreadsheetTextOrientationFromXlsx, spreadsheetUnderlineCellValue, spreadsheetUnderlineCellValueFromSheetJs, spreadsheetUnderlineCellValueFromXlsx, spreadsheetUnderlineStyle, spreadsheetVisibleTextRotationFromCell, synchronizeSpreadsheetTableTotalsRow, validXlsxRichText, withDefaultSpreadsheetTableTotalsLabel, writeXlsxRichTextCells, xlsxAlignmentMatches, xlsxBooleanAttribute, xlsxBorderLineMatches, xlsxColorMatches, xlsxNativeFillCellKeys, xlsxNativeFillKey, xlsxNativeFillSemanticColors, xlsxRichTextCellText, xlsxRichTextStyleOrigins, xlsxStyleCollectionIndex, xlsxToggleEnabled, xlsxUnderlineStyle };
|