exceljs-lts 4.5.1 → 4.5.3
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/es5/doc/table.js +89 -2
- package/dist/es5/doc/table.js.map +1 -1
- package/dist/es5/doc/worksheet.js +12 -6
- package/dist/es5/doc/worksheet.js.map +1 -1
- package/dist/es5/stream/xlsx/workbook-reader.js +69 -62
- package/dist/es5/stream/xlsx/workbook-reader.js.map +1 -1
- package/dist/es5/xlsx/xform/book/workbook-xform.js +34 -9
- package/dist/es5/xlsx/xform/book/workbook-xform.js.map +1 -1
- package/dist/es5/xlsx/xform/sheet/cf/cf-rule-xform.js +4 -0
- package/dist/es5/xlsx/xform/sheet/cf/cf-rule-xform.js.map +1 -1
- package/dist/es5/xlsx/xform/sheet/cf/conditional-formattings-xform.js +4 -1
- package/dist/es5/xlsx/xform/sheet/cf/conditional-formattings-xform.js.map +1 -1
- package/dist/es5/xlsx/xform/sheet/cf-ext/cf-rule-ext-xform.js +40 -2
- package/dist/es5/xlsx/xform/sheet/cf-ext/cf-rule-ext-xform.js.map +1 -1
- package/dist/es5/xlsx/xform/style/dxf-ext-xform.js +24 -0
- package/dist/es5/xlsx/xform/style/dxf-ext-xform.js.map +1 -0
- package/dist/es5/xlsx/xform/table/table-xform.js +2 -1
- package/dist/es5/xlsx/xform/table/table-xform.js.map +1 -1
- package/dist/exceljs.bare.js +621 -432
- package/dist/exceljs.bare.js.map +11 -9
- package/dist/exceljs.bare.min.js +8 -8
- package/dist/exceljs.bare.min.js.map +1 -1
- package/dist/exceljs.js +786 -597
- package/dist/exceljs.js.map +11 -9
- package/dist/exceljs.min.js +8 -8
- package/dist/exceljs.min.js.map +1 -1
- package/lib/doc/table.js +89 -2
- package/lib/doc/worksheet.js +15 -6
- package/lib/stream/xlsx/workbook-reader.js +64 -54
- package/lib/xlsx/xform/book/workbook-xform.js +42 -11
- package/lib/xlsx/xform/sheet/cf/cf-rule-xform.js +4 -0
- package/lib/xlsx/xform/sheet/cf/conditional-formattings-xform.js +3 -1
- package/lib/xlsx/xform/sheet/cf-ext/cf-rule-ext-xform.js +42 -1
- package/lib/xlsx/xform/style/dxf-ext-xform.js +19 -0
- package/lib/xlsx/xform/table/table-xform.js +2 -1
- package/package.json +1 -1
package/dist/es5/doc/table.js
CHANGED
|
@@ -124,8 +124,9 @@ class Table {
|
|
|
124
124
|
return this.table.columns.length;
|
|
125
125
|
}
|
|
126
126
|
get height() {
|
|
127
|
-
// height of the table data
|
|
128
|
-
|
|
127
|
+
// height of the table data. Excel needs at least one data row, so an empty table
|
|
128
|
+
// keeps one blank row on the sheet (it is not added to table.rows)
|
|
129
|
+
return Math.max(this.table.rows.length, 1);
|
|
129
130
|
}
|
|
130
131
|
get filterHeight() {
|
|
131
132
|
// height of the table data plus optional header row
|
|
@@ -230,6 +231,15 @@ class Table {
|
|
|
230
231
|
assignStyle(cell, table.columns[j].style);
|
|
231
232
|
});
|
|
232
233
|
});
|
|
234
|
+
if (!table.rows.length) {
|
|
235
|
+
// blank placeholder row so the table keeps a valid ref
|
|
236
|
+
const r = worksheet.getRow(row + count++);
|
|
237
|
+
table.columns.forEach((column, j) => {
|
|
238
|
+
const cell = r.getCell(col + j);
|
|
239
|
+
cell.value = null;
|
|
240
|
+
assignStyle(cell, column.style);
|
|
241
|
+
});
|
|
242
|
+
}
|
|
233
243
|
if (table.totalsRow) {
|
|
234
244
|
const r = worksheet.getRow(row + count++);
|
|
235
245
|
table.columns.forEach((column, j) => {
|
|
@@ -275,6 +285,10 @@ class Table {
|
|
|
275
285
|
cell.value = value;
|
|
276
286
|
});
|
|
277
287
|
});
|
|
288
|
+
if (!table.rows.length) {
|
|
289
|
+
// skip the blank placeholder row of an empty table
|
|
290
|
+
count++;
|
|
291
|
+
}
|
|
278
292
|
if (table.totalsRow) {
|
|
279
293
|
const r = worksheet.getRow(row + count++);
|
|
280
294
|
table.columns.forEach((column, j) => {
|
|
@@ -298,6 +312,79 @@ class Table {
|
|
|
298
312
|
}
|
|
299
313
|
set model(value) {
|
|
300
314
|
this.table = value;
|
|
315
|
+
if (this.worksheet && !value.rows) {
|
|
316
|
+
// a table parsed from a file has no rows: read them from the sheet cells
|
|
317
|
+
this.loadRows();
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
loadRows() {
|
|
321
|
+
// rebuild ref, column names, rows and totals row formulas of a table parsed from a file
|
|
322
|
+
// from the cells inside its tableRef. This only reads the sheet, it never writes to it.
|
|
323
|
+
const {
|
|
324
|
+
worksheet,
|
|
325
|
+
table
|
|
326
|
+
} = this;
|
|
327
|
+
if (table.headerRow === undefined) {
|
|
328
|
+
table.headerRow = true;
|
|
329
|
+
}
|
|
330
|
+
if (table.totalsRow === undefined) {
|
|
331
|
+
table.totalsRow = false;
|
|
332
|
+
}
|
|
333
|
+
if (!table.style) {
|
|
334
|
+
table.style = {};
|
|
335
|
+
}
|
|
336
|
+
table.columns = table.columns || [];
|
|
337
|
+
const range = colCache.decode(table.tableRef || table.ref);
|
|
338
|
+
const top = range.top || range.row;
|
|
339
|
+
const left = range.left || range.col;
|
|
340
|
+
const bottom = range.bottom || top;
|
|
341
|
+
if (!table.ref) {
|
|
342
|
+
table.ref = colCache.encodeAddress(top, left);
|
|
343
|
+
}
|
|
344
|
+
const cellValue = (r, c) => {
|
|
345
|
+
const cell = worksheet.findCell(r, c);
|
|
346
|
+
return cell ? cell.value : null;
|
|
347
|
+
};
|
|
348
|
+
let first = top;
|
|
349
|
+
let last = bottom;
|
|
350
|
+
if (table.headerRow) {
|
|
351
|
+
table.columns.forEach((column, j) => {
|
|
352
|
+
if (!column.name) {
|
|
353
|
+
const value = cellValue(top, left + j);
|
|
354
|
+
column.name = value === null || value === undefined ? `Column${j + 1}` : `${value}`;
|
|
355
|
+
}
|
|
356
|
+
});
|
|
357
|
+
first++;
|
|
358
|
+
}
|
|
359
|
+
if (table.totalsRow) {
|
|
360
|
+
table.columns.forEach((column, j) => {
|
|
361
|
+
const cell = worksheet.findCell(bottom, left + j);
|
|
362
|
+
if (!cell) {
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
if (j === 0) {
|
|
366
|
+
if (column.totalsRowLabel === undefined && typeof cell.value === 'string') {
|
|
367
|
+
column.totalsRowLabel = cell.value;
|
|
368
|
+
}
|
|
369
|
+
} else if (cell.formula) {
|
|
370
|
+
if (column.totalsRowFunction === 'custom' && column.totalsRowFormula === undefined) {
|
|
371
|
+
column.totalsRowFormula = cell.formula;
|
|
372
|
+
}
|
|
373
|
+
if (column.totalsRowResult === undefined) {
|
|
374
|
+
column.totalsRowResult = cell.result;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
});
|
|
378
|
+
last--;
|
|
379
|
+
}
|
|
380
|
+
table.rows = [];
|
|
381
|
+
for (let r = first; r <= last; r++) {
|
|
382
|
+
table.rows.push(table.columns.map((column, j) => cellValue(r, left + j)));
|
|
383
|
+
}
|
|
384
|
+
if (table.rows.length === 1 && table.rows[0].every(v => v === null || v === undefined)) {
|
|
385
|
+
// the blank placeholder row of an empty table
|
|
386
|
+
table.rows = [];
|
|
387
|
+
}
|
|
301
388
|
}
|
|
302
389
|
|
|
303
390
|
// ================================================================
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.js","names":["colCache","require","tableNameRegex","isCellReference","name","test","match","exec","letters","toUpperCase","isColumn","length","row","parseInt","isValidTableName","Column","constructor","table","column","index","_set","value","cacheState","filterButton","style","totalsRowLabel","totalsRowFunction","totalsRowResult","totalsRowFormula","Table","worksheet","validate","store","getFormula","Error","width","columns","height","rows","filterHeight","headerRow","tableHeight","totalsRow","assign","o","dflt","undefined","assert","message","ref","tl","decodeAddress","col","autoFilterRef","encode","tableRef","forEach","i","assignStyle","cell","Object","keys","key","count","r","getRow","j","getCell","data","formula","result","load","model","_cache","commit","addRow","values","rowNumber","push","splice","removeRows","rowIndex","getColumn","colIndex","addColumn","removeColumns","_assign","target","prop","displayName","displyName","displayNamename","theme","showFirstColumn","showLastColumn","showRowStripes","showColumnStripes","module","exports"],"sources":["../../../lib/doc/table.js"],"sourcesContent":["/* eslint-disable max-classes-per-file */\nconst colCache = require('../utils/col-cache');\n\n// Excel's rules for table names: start with a letter, '_' or '\\\\', then letters, digits, '.' or\n// '_'; at most 255 characters; and the name must not be read as a cell reference.\n// Any non-ASCII character is treated as a letter so that names Excel accepts keep working.\nconst tableNameRegex = /^[A-Za-z_\\\\\\u0080-\\uFFFF][A-Za-z0-9._\\u0080-\\uFFFF]*$/;\n\nfunction isCellReference(name) {\n if (/^[RC]$/i.test(name) || /^R\\d*C\\d*$/i.test(name)) {\n // 'R', 'C' and R1C1-style references such as 'R1C1' or 'RC'\n return true;\n }\n const match = /^([A-Z]{1,3})(\\d+)$/i.exec(name);\n if (!match) {\n return false;\n }\n // letters past XFD are not a column, so a name like 'ZZZ1' is fine\n const letters = match[1].toUpperCase();\n const isColumn = letters.length < 3 || letters <= 'XFD';\n const row = parseInt(match[2], 10);\n return isColumn && row >= 1 && row <= 1048576;\n}\n\nfunction isValidTableName(name) {\n return (\n typeof name === 'string' &&\n name.length <= 255 &&\n tableNameRegex.test(name) &&\n !isCellReference(name)\n );\n}\n\nclass Column {\n // wrapper around column model, allowing access and manipulation\n constructor(table, column, index) {\n this.table = table;\n this.column = column;\n this.index = index;\n }\n\n _set(name, value) {\n this.table.cacheState();\n this.column[name] = value;\n }\n\n /* eslint-disable lines-between-class-members */\n get name() {\n return this.column.name;\n }\n set name(value) {\n this._set('name', value);\n }\n\n get filterButton() {\n return this.column.filterButton;\n }\n set filterButton(value) {\n this.column.filterButton = value;\n }\n\n get style() {\n return this.column.style;\n }\n set style(value) {\n this.column.style = value;\n }\n\n get totalsRowLabel() {\n return this.column.totalsRowLabel;\n }\n set totalsRowLabel(value) {\n this._set('totalsRowLabel', value);\n }\n\n get totalsRowFunction() {\n return this.column.totalsRowFunction;\n }\n set totalsRowFunction(value) {\n this._set('totalsRowFunction', value);\n }\n\n get totalsRowResult() {\n return this.column.totalsRowResult;\n }\n set totalsRowResult(value) {\n this._set('totalsRowResult', value);\n }\n\n get totalsRowFormula() {\n return this.column.totalsRowFormula;\n }\n set totalsRowFormula(value) {\n this._set('totalsRowFormula', value);\n }\n /* eslint-enable lines-between-class-members */\n}\n\nclass Table {\n constructor(worksheet, table) {\n this.worksheet = worksheet;\n if (table) {\n this.table = table;\n // check things are ok first\n this.validate();\n\n this.store();\n }\n }\n\n getFormula(column) {\n // get the correct formula to apply to the totals row\n switch (column.totalsRowFunction) {\n case 'none':\n return null;\n case 'average':\n return `SUBTOTAL(101,${this.table.name}[${column.name}])`;\n case 'countNums':\n return `SUBTOTAL(102,${this.table.name}[${column.name}])`;\n case 'count':\n return `SUBTOTAL(103,${this.table.name}[${column.name}])`;\n case 'max':\n return `SUBTOTAL(104,${this.table.name}[${column.name}])`;\n case 'min':\n return `SUBTOTAL(105,${this.table.name}[${column.name}])`;\n case 'stdDev':\n return `SUBTOTAL(106,${this.table.name}[${column.name}])`;\n case 'var':\n return `SUBTOTAL(107,${this.table.name}[${column.name}])`;\n case 'sum':\n return `SUBTOTAL(109,${this.table.name}[${column.name}])`;\n case 'custom':\n return column.totalsRowFormula;\n default:\n throw new Error(`Invalid Totals Row Function: ${column.totalsRowFunction}`);\n }\n }\n\n get width() {\n // width of the table\n return this.table.columns.length;\n }\n\n get height() {\n // height of the table data\n return this.table.rows.length;\n }\n\n get filterHeight() {\n // height of the table data plus optional header row\n return this.height + (this.table.headerRow ? 1 : 0);\n }\n\n get tableHeight() {\n // full height of the table on the sheet\n return this.filterHeight + (this.table.totalsRow ? 1 : 0);\n }\n\n validate() {\n const {table} = this;\n // set defaults and check is valid\n const assign = (o, name, dflt) => {\n if (o[name] === undefined) {\n o[name] = dflt;\n }\n };\n assign(table, 'headerRow', true);\n assign(table, 'totalsRow', false);\n\n assign(table, 'style', {});\n assign(table.style, 'theme', 'TableStyleMedium2');\n assign(table.style, 'showFirstColumn', false);\n assign(table.style, 'showLastColumn', false);\n assign(table.style, 'showRowStripes', false);\n assign(table.style, 'showColumnStripes', false);\n\n const assert = (test, message) => {\n if (!test) {\n throw new Error(message);\n }\n };\n assert(table.name, 'Table must have a name');\n assert(\n isValidTableName(table.name),\n `Invalid table name '${table.name}'. A table name must start with a letter, underscore ` +\n 'or backslash, contain only letters, digits, periods and underscores, ' +\n 'not look like a cell reference and be at most 255 characters long.'\n );\n assert(table.ref, 'Table must have ref');\n assert(table.columns, 'Table must have column definitions');\n assert(table.rows, 'Table must have row definitions');\n\n table.tl = colCache.decodeAddress(table.ref);\n const {row, col} = table.tl;\n assert(row > 0, 'Table must be on valid row');\n assert(col > 0, 'Table must be on valid col');\n\n const {width, filterHeight, tableHeight} = this;\n\n // autoFilterRef is a range that includes optional headers only\n table.autoFilterRef = colCache.encode(row, col, row + filterHeight - 1, col + width - 1);\n\n // tableRef is a range that includes optional headers and totals\n table.tableRef = colCache.encode(row, col, row + tableHeight - 1, col + width - 1);\n\n table.columns.forEach((column, i) => {\n assert(column.name, `Column ${i} must have a name`);\n if (i === 0) {\n assign(column, 'totalsRowLabel', 'Total');\n } else {\n assign(column, 'totalsRowFunction', 'none');\n column.totalsRowFormula = this.getFormula(column);\n }\n });\n }\n\n store() {\n // where the table needs to store table data, headers, footers in\n // the sheet...\n const assignStyle = (cell, style) => {\n if (style) {\n Object.keys(style).forEach(key => {\n cell.style[key] = style[key];\n });\n }\n };\n\n const {worksheet, table} = this;\n const {row, col} = table.tl;\n let count = 0;\n if (table.headerRow) {\n const r = worksheet.getRow(row + count++);\n table.columns.forEach((column, j) => {\n const {style, name} = column;\n const cell = r.getCell(col + j);\n cell.value = name;\n assignStyle(cell, style);\n });\n }\n table.rows.forEach(data => {\n const r = worksheet.getRow(row + count++);\n data.forEach((value, j) => {\n const cell = r.getCell(col + j);\n cell.value = value;\n\n assignStyle(cell, table.columns[j].style);\n });\n });\n\n if (table.totalsRow) {\n const r = worksheet.getRow(row + count++);\n table.columns.forEach((column, j) => {\n const cell = r.getCell(col + j);\n if (j === 0) {\n cell.value = column.totalsRowLabel;\n } else {\n const formula = this.getFormula(column);\n if (formula) {\n cell.value = {\n formula: column.totalsRowFormula,\n result: column.totalsRowResult,\n };\n } else {\n cell.value = null;\n }\n }\n\n assignStyle(cell, column.style);\n });\n }\n }\n\n load(worksheet) {\n // where the table will read necessary features from a loaded sheet\n const {table} = this;\n const {row, col} = table.tl;\n let count = 0;\n if (table.headerRow) {\n const r = worksheet.getRow(row + count++);\n table.columns.forEach((column, j) => {\n const cell = r.getCell(col + j);\n cell.value = column.name;\n });\n }\n table.rows.forEach(data => {\n const r = worksheet.getRow(row + count++);\n data.forEach((value, j) => {\n const cell = r.getCell(col + j);\n cell.value = value;\n });\n });\n\n if (table.totalsRow) {\n const r = worksheet.getRow(row + count++);\n table.columns.forEach((column, j) => {\n const cell = r.getCell(col + j);\n if (j === 0) {\n cell.value = column.totalsRowLabel;\n } else {\n const formula = this.getFormula(column);\n if (formula) {\n cell.value = {\n formula: column.totalsRowFormula,\n result: column.totalsRowResult,\n };\n }\n }\n });\n }\n }\n\n get model() {\n return this.table;\n }\n\n set model(value) {\n this.table = value;\n }\n\n // ================================================================\n // TODO: Mutating methods\n cacheState() {\n if (!this._cache) {\n this._cache = {\n ref: this.ref,\n width: this.width,\n tableHeight: this.tableHeight,\n };\n }\n }\n\n commit() {\n // changes may have been made that might have on-sheet effects\n if (!this._cache) {\n return;\n }\n\n // check things are ok first\n this.validate();\n\n const ref = colCache.decodeAddress(this._cache.ref);\n if (this.ref !== this._cache.ref) {\n // wipe out whole table footprint at previous location\n for (let i = 0; i < this._cache.tableHeight; i++) {\n const row = this.worksheet.getRow(ref.row + i);\n for (let j = 0; j < this._cache.width; j++) {\n const cell = row.getCell(ref.col + j);\n cell.value = null;\n }\n }\n } else {\n // clear out below table if it has shrunk\n for (let i = this.tableHeight; i < this._cache.tableHeight; i++) {\n const row = this.worksheet.getRow(ref.row + i);\n for (let j = 0; j < this._cache.width; j++) {\n const cell = row.getCell(ref.col + j);\n cell.value = null;\n }\n }\n\n // clear out to right of table if it has lost columns\n for (let i = 0; i < this.tableHeight; i++) {\n const row = this.worksheet.getRow(ref.row + i);\n for (let j = this.width; j < this._cache.width; j++) {\n const cell = row.getCell(ref.col + j);\n cell.value = null;\n }\n }\n }\n\n this.store();\n }\n\n addRow(values, rowNumber) {\n // Add a row of data, either insert at rowNumber or append\n this.cacheState();\n\n if (rowNumber === undefined) {\n this.table.rows.push(values);\n } else {\n this.table.rows.splice(rowNumber, 0, values);\n }\n }\n\n removeRows(rowIndex, count = 1) {\n // Remove a rows of data\n this.cacheState();\n this.table.rows.splice(rowIndex, count);\n }\n\n getColumn(colIndex) {\n const column = this.table.columns[colIndex];\n return new Column(this, column, colIndex);\n }\n\n addColumn(column, values, colIndex) {\n // Add a new column, including column defn and values\n // Inserts at colNumber or adds to the right\n this.cacheState();\n\n if (colIndex === undefined) {\n this.table.columns.push(column);\n this.table.rows.forEach((row, i) => {\n row.push(values[i]);\n });\n } else {\n this.table.columns.splice(colIndex, 0, column);\n this.table.rows.forEach((row, i) => {\n row.splice(colIndex, 0, values[i]);\n });\n }\n }\n\n removeColumns(colIndex, count = 1) {\n // Remove a column with data\n this.cacheState();\n\n this.table.columns.splice(colIndex, count);\n this.table.rows.forEach(row => {\n row.splice(colIndex, count);\n });\n }\n\n _assign(target, prop, value) {\n this.cacheState();\n target[prop] = value;\n }\n\n /* eslint-disable lines-between-class-members */\n get ref() {\n return this.table.ref;\n }\n set ref(value) {\n this._assign(this.table, 'ref', value);\n }\n\n get name() {\n return this.table.name;\n }\n set name(value) {\n this.table.name = value;\n }\n\n get displayName() {\n return this.table.displyName || this.table.name;\n }\n set displayNamename(value) {\n this.table.displayName = value;\n }\n\n get headerRow() {\n return this.table.headerRow;\n }\n set headerRow(value) {\n this._assign(this.table, 'headerRow', value);\n }\n\n get totalsRow() {\n return this.table.totalsRow;\n }\n set totalsRow(value) {\n this._assign(this.table, 'totalsRow', value);\n }\n\n get theme() {\n return this.table.style.name;\n }\n set theme(value) {\n this.table.style.name = value;\n }\n\n get showFirstColumn() {\n return this.table.style.showFirstColumn;\n }\n set showFirstColumn(value) {\n this.table.style.showFirstColumn = value;\n }\n\n get showLastColumn() {\n return this.table.style.showLastColumn;\n }\n set showLastColumn(value) {\n this.table.style.showLastColumn = value;\n }\n\n get showRowStripes() {\n return this.table.style.showRowStripes;\n }\n set showRowStripes(value) {\n this.table.style.showRowStripes = value;\n }\n\n get showColumnStripes() {\n return this.table.style.showColumnStripes;\n }\n set showColumnStripes(value) {\n this.table.style.showColumnStripes = value;\n }\n /* eslint-enable lines-between-class-members */\n}\n\nmodule.exports = Table;\n"],"mappings":";;AAAA;AACA,MAAMA,QAAQ,GAAGC,OAAO,CAAC,oBAAoB,CAAC;;AAE9C;AACA;AACA;AACA,MAAMC,cAAc,GAAG,uDAAuD;AAE9E,SAASC,eAAeA,CAACC,IAAI,EAAE;EAC7B,IAAI,SAAS,CAACC,IAAI,CAACD,IAAI,CAAC,IAAI,aAAa,CAACC,IAAI,CAACD,IAAI,CAAC,EAAE;IACpD;IACA,OAAO,IAAI;EACb;EACA,MAAME,KAAK,GAAG,sBAAsB,CAACC,IAAI,CAACH,IAAI,CAAC;EAC/C,IAAI,CAACE,KAAK,EAAE;IACV,OAAO,KAAK;EACd;EACA;EACA,MAAME,OAAO,GAAGF,KAAK,CAAC,CAAC,CAAC,CAACG,WAAW,CAAC,CAAC;EACtC,MAAMC,QAAQ,GAAGF,OAAO,CAACG,MAAM,GAAG,CAAC,IAAIH,OAAO,IAAI,KAAK;EACvD,MAAMI,GAAG,GAAGC,QAAQ,CAACP,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;EAClC,OAAOI,QAAQ,IAAIE,GAAG,IAAI,CAAC,IAAIA,GAAG,IAAI,OAAO;AAC/C;AAEA,SAASE,gBAAgBA,CAACV,IAAI,EAAE;EAC9B,OACE,OAAOA,IAAI,KAAK,QAAQ,IACxBA,IAAI,CA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;AAEA4E,MAAM,CAACC,OAAO,GAAGrE,KAAK","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"table.js","names":["colCache","require","tableNameRegex","isCellReference","name","test","match","exec","letters","toUpperCase","isColumn","length","row","parseInt","isValidTableName","Column","constructor","table","column","index","_set","value","cacheState","filterButton","style","totalsRowLabel","totalsRowFunction","totalsRowResult","totalsRowFormula","Table","worksheet","validate","store","getFormula","Error","width","columns","height","Math","max","rows","filterHeight","headerRow","tableHeight","totalsRow","assign","o","dflt","undefined","assert","message","ref","tl","decodeAddress","col","autoFilterRef","encode","tableRef","forEach","i","assignStyle","cell","Object","keys","key","count","r","getRow","j","getCell","data","formula","result","load","model","loadRows","range","decode","top","left","bottom","encodeAddress","cellValue","c","findCell","first","last","push","map","every","v","_cache","commit","addRow","values","rowNumber","splice","removeRows","rowIndex","getColumn","colIndex","addColumn","removeColumns","_assign","target","prop","displayName","displyName","displayNamename","theme","showFirstColumn","showLastColumn","showRowStripes","showColumnStripes","module","exports"],"sources":["../../../lib/doc/table.js"],"sourcesContent":["/* eslint-disable max-classes-per-file */\nconst colCache = require('../utils/col-cache');\n\n// Excel's rules for table names: start with a letter, '_' or '\\\\', then letters, digits, '.' or\n// '_'; at most 255 characters; and the name must not be read as a cell reference.\n// Any non-ASCII character is treated as a letter so that names Excel accepts keep working.\nconst tableNameRegex = /^[A-Za-z_\\\\\\u0080-\\uFFFF][A-Za-z0-9._\\u0080-\\uFFFF]*$/;\n\nfunction isCellReference(name) {\n if (/^[RC]$/i.test(name) || /^R\\d*C\\d*$/i.test(name)) {\n // 'R', 'C' and R1C1-style references such as 'R1C1' or 'RC'\n return true;\n }\n const match = /^([A-Z]{1,3})(\\d+)$/i.exec(name);\n if (!match) {\n return false;\n }\n // letters past XFD are not a column, so a name like 'ZZZ1' is fine\n const letters = match[1].toUpperCase();\n const isColumn = letters.length < 3 || letters <= 'XFD';\n const row = parseInt(match[2], 10);\n return isColumn && row >= 1 && row <= 1048576;\n}\n\nfunction isValidTableName(name) {\n return (\n typeof name === 'string' &&\n name.length <= 255 &&\n tableNameRegex.test(name) &&\n !isCellReference(name)\n );\n}\n\nclass Column {\n // wrapper around column model, allowing access and manipulation\n constructor(table, column, index) {\n this.table = table;\n this.column = column;\n this.index = index;\n }\n\n _set(name, value) {\n this.table.cacheState();\n this.column[name] = value;\n }\n\n /* eslint-disable lines-between-class-members */\n get name() {\n return this.column.name;\n }\n set name(value) {\n this._set('name', value);\n }\n\n get filterButton() {\n return this.column.filterButton;\n }\n set filterButton(value) {\n this.column.filterButton = value;\n }\n\n get style() {\n return this.column.style;\n }\n set style(value) {\n this.column.style = value;\n }\n\n get totalsRowLabel() {\n return this.column.totalsRowLabel;\n }\n set totalsRowLabel(value) {\n this._set('totalsRowLabel', value);\n }\n\n get totalsRowFunction() {\n return this.column.totalsRowFunction;\n }\n set totalsRowFunction(value) {\n this._set('totalsRowFunction', value);\n }\n\n get totalsRowResult() {\n return this.column.totalsRowResult;\n }\n set totalsRowResult(value) {\n this._set('totalsRowResult', value);\n }\n\n get totalsRowFormula() {\n return this.column.totalsRowFormula;\n }\n set totalsRowFormula(value) {\n this._set('totalsRowFormula', value);\n }\n /* eslint-enable lines-between-class-members */\n}\n\nclass Table {\n constructor(worksheet, table) {\n this.worksheet = worksheet;\n if (table) {\n this.table = table;\n // check things are ok first\n this.validate();\n\n this.store();\n }\n }\n\n getFormula(column) {\n // get the correct formula to apply to the totals row\n switch (column.totalsRowFunction) {\n case 'none':\n return null;\n case 'average':\n return `SUBTOTAL(101,${this.table.name}[${column.name}])`;\n case 'countNums':\n return `SUBTOTAL(102,${this.table.name}[${column.name}])`;\n case 'count':\n return `SUBTOTAL(103,${this.table.name}[${column.name}])`;\n case 'max':\n return `SUBTOTAL(104,${this.table.name}[${column.name}])`;\n case 'min':\n return `SUBTOTAL(105,${this.table.name}[${column.name}])`;\n case 'stdDev':\n return `SUBTOTAL(106,${this.table.name}[${column.name}])`;\n case 'var':\n return `SUBTOTAL(107,${this.table.name}[${column.name}])`;\n case 'sum':\n return `SUBTOTAL(109,${this.table.name}[${column.name}])`;\n case 'custom':\n return column.totalsRowFormula;\n default:\n throw new Error(`Invalid Totals Row Function: ${column.totalsRowFunction}`);\n }\n }\n\n get width() {\n // width of the table\n return this.table.columns.length;\n }\n\n get height() {\n // height of the table data. Excel needs at least one data row, so an empty table\n // keeps one blank row on the sheet (it is not added to table.rows)\n return Math.max(this.table.rows.length, 1);\n }\n\n get filterHeight() {\n // height of the table data plus optional header row\n return this.height + (this.table.headerRow ? 1 : 0);\n }\n\n get tableHeight() {\n // full height of the table on the sheet\n return this.filterHeight + (this.table.totalsRow ? 1 : 0);\n }\n\n validate() {\n const {table} = this;\n // set defaults and check is valid\n const assign = (o, name, dflt) => {\n if (o[name] === undefined) {\n o[name] = dflt;\n }\n };\n assign(table, 'headerRow', true);\n assign(table, 'totalsRow', false);\n\n assign(table, 'style', {});\n assign(table.style, 'theme', 'TableStyleMedium2');\n assign(table.style, 'showFirstColumn', false);\n assign(table.style, 'showLastColumn', false);\n assign(table.style, 'showRowStripes', false);\n assign(table.style, 'showColumnStripes', false);\n\n const assert = (test, message) => {\n if (!test) {\n throw new Error(message);\n }\n };\n assert(table.name, 'Table must have a name');\n assert(\n isValidTableName(table.name),\n `Invalid table name '${table.name}'. A table name must start with a letter, underscore ` +\n 'or backslash, contain only letters, digits, periods and underscores, ' +\n 'not look like a cell reference and be at most 255 characters long.'\n );\n assert(table.ref, 'Table must have ref');\n assert(table.columns, 'Table must have column definitions');\n assert(table.rows, 'Table must have row definitions');\n\n table.tl = colCache.decodeAddress(table.ref);\n const {row, col} = table.tl;\n assert(row > 0, 'Table must be on valid row');\n assert(col > 0, 'Table must be on valid col');\n\n const {width, filterHeight, tableHeight} = this;\n\n // autoFilterRef is a range that includes optional headers only\n table.autoFilterRef = colCache.encode(row, col, row + filterHeight - 1, col + width - 1);\n\n // tableRef is a range that includes optional headers and totals\n table.tableRef = colCache.encode(row, col, row + tableHeight - 1, col + width - 1);\n\n table.columns.forEach((column, i) => {\n assert(column.name, `Column ${i} must have a name`);\n if (i === 0) {\n assign(column, 'totalsRowLabel', 'Total');\n } else {\n assign(column, 'totalsRowFunction', 'none');\n column.totalsRowFormula = this.getFormula(column);\n }\n });\n }\n\n store() {\n // where the table needs to store table data, headers, footers in\n // the sheet...\n const assignStyle = (cell, style) => {\n if (style) {\n Object.keys(style).forEach(key => {\n cell.style[key] = style[key];\n });\n }\n };\n\n const {worksheet, table} = this;\n const {row, col} = table.tl;\n let count = 0;\n if (table.headerRow) {\n const r = worksheet.getRow(row + count++);\n table.columns.forEach((column, j) => {\n const {style, name} = column;\n const cell = r.getCell(col + j);\n cell.value = name;\n assignStyle(cell, style);\n });\n }\n table.rows.forEach(data => {\n const r = worksheet.getRow(row + count++);\n data.forEach((value, j) => {\n const cell = r.getCell(col + j);\n cell.value = value;\n\n assignStyle(cell, table.columns[j].style);\n });\n });\n if (!table.rows.length) {\n // blank placeholder row so the table keeps a valid ref\n const r = worksheet.getRow(row + count++);\n table.columns.forEach((column, j) => {\n const cell = r.getCell(col + j);\n cell.value = null;\n assignStyle(cell, column.style);\n });\n }\n\n if (table.totalsRow) {\n const r = worksheet.getRow(row + count++);\n table.columns.forEach((column, j) => {\n const cell = r.getCell(col + j);\n if (j === 0) {\n cell.value = column.totalsRowLabel;\n } else {\n const formula = this.getFormula(column);\n if (formula) {\n cell.value = {\n formula: column.totalsRowFormula,\n result: column.totalsRowResult,\n };\n } else {\n cell.value = null;\n }\n }\n\n assignStyle(cell, column.style);\n });\n }\n }\n\n load(worksheet) {\n // where the table will read necessary features from a loaded sheet\n const {table} = this;\n const {row, col} = table.tl;\n let count = 0;\n if (table.headerRow) {\n const r = worksheet.getRow(row + count++);\n table.columns.forEach((column, j) => {\n const cell = r.getCell(col + j);\n cell.value = column.name;\n });\n }\n table.rows.forEach(data => {\n const r = worksheet.getRow(row + count++);\n data.forEach((value, j) => {\n const cell = r.getCell(col + j);\n cell.value = value;\n });\n });\n if (!table.rows.length) {\n // skip the blank placeholder row of an empty table\n count++;\n }\n\n if (table.totalsRow) {\n const r = worksheet.getRow(row + count++);\n table.columns.forEach((column, j) => {\n const cell = r.getCell(col + j);\n if (j === 0) {\n cell.value = column.totalsRowLabel;\n } else {\n const formula = this.getFormula(column);\n if (formula) {\n cell.value = {\n formula: column.totalsRowFormula,\n result: column.totalsRowResult,\n };\n }\n }\n });\n }\n }\n\n get model() {\n return this.table;\n }\n\n set model(value) {\n this.table = value;\n if (this.worksheet && !value.rows) {\n // a table parsed from a file has no rows: read them from the sheet cells\n this.loadRows();\n }\n }\n\n loadRows() {\n // rebuild ref, column names, rows and totals row formulas of a table parsed from a file\n // from the cells inside its tableRef. This only reads the sheet, it never writes to it.\n const {worksheet, table} = this;\n if (table.headerRow === undefined) {\n table.headerRow = true;\n }\n if (table.totalsRow === undefined) {\n table.totalsRow = false;\n }\n if (!table.style) {\n table.style = {};\n }\n table.columns = table.columns || [];\n const range = colCache.decode(table.tableRef || table.ref);\n const top = range.top || range.row;\n const left = range.left || range.col;\n const bottom = range.bottom || top;\n if (!table.ref) {\n table.ref = colCache.encodeAddress(top, left);\n }\n const cellValue = (r, c) => {\n const cell = worksheet.findCell(r, c);\n return cell ? cell.value : null;\n };\n\n let first = top;\n let last = bottom;\n if (table.headerRow) {\n table.columns.forEach((column, j) => {\n if (!column.name) {\n const value = cellValue(top, left + j);\n column.name = value === null || value === undefined ? `Column${j + 1}` : `${value}`;\n }\n });\n first++;\n }\n if (table.totalsRow) {\n table.columns.forEach((column, j) => {\n const cell = worksheet.findCell(bottom, left + j);\n if (!cell) {\n return;\n }\n if (j === 0) {\n if (column.totalsRowLabel === undefined && typeof cell.value === 'string') {\n column.totalsRowLabel = cell.value;\n }\n } else if (cell.formula) {\n if (column.totalsRowFunction === 'custom' && column.totalsRowFormula === undefined) {\n column.totalsRowFormula = cell.formula;\n }\n if (column.totalsRowResult === undefined) {\n column.totalsRowResult = cell.result;\n }\n }\n });\n last--;\n }\n\n table.rows = [];\n for (let r = first; r <= last; r++) {\n table.rows.push(table.columns.map((column, j) => cellValue(r, left + j)));\n }\n if (table.rows.length === 1 && table.rows[0].every(v => v === null || v === undefined)) {\n // the blank placeholder row of an empty table\n table.rows = [];\n }\n }\n\n // ================================================================\n // TODO: Mutating methods\n cacheState() {\n if (!this._cache) {\n this._cache = {\n ref: this.ref,\n width: this.width,\n tableHeight: this.tableHeight,\n };\n }\n }\n\n commit() {\n // changes may have been made that might have on-sheet effects\n if (!this._cache) {\n return;\n }\n\n // check things are ok first\n this.validate();\n\n const ref = colCache.decodeAddress(this._cache.ref);\n if (this.ref !== this._cache.ref) {\n // wipe out whole table footprint at previous location\n for (let i = 0; i < this._cache.tableHeight; i++) {\n const row = this.worksheet.getRow(ref.row + i);\n for (let j = 0; j < this._cache.width; j++) {\n const cell = row.getCell(ref.col + j);\n cell.value = null;\n }\n }\n } else {\n // clear out below table if it has shrunk\n for (let i = this.tableHeight; i < this._cache.tableHeight; i++) {\n const row = this.worksheet.getRow(ref.row + i);\n for (let j = 0; j < this._cache.width; j++) {\n const cell = row.getCell(ref.col + j);\n cell.value = null;\n }\n }\n\n // clear out to right of table if it has lost columns\n for (let i = 0; i < this.tableHeight; i++) {\n const row = this.worksheet.getRow(ref.row + i);\n for (let j = this.width; j < this._cache.width; j++) {\n const cell = row.getCell(ref.col + j);\n cell.value = null;\n }\n }\n }\n\n this.store();\n }\n\n addRow(values, rowNumber) {\n // Add a row of data, either insert at rowNumber or append\n this.cacheState();\n\n if (rowNumber === undefined) {\n this.table.rows.push(values);\n } else {\n this.table.rows.splice(rowNumber, 0, values);\n }\n }\n\n removeRows(rowIndex, count = 1) {\n // Remove a rows of data\n this.cacheState();\n this.table.rows.splice(rowIndex, count);\n }\n\n getColumn(colIndex) {\n const column = this.table.columns[colIndex];\n return new Column(this, column, colIndex);\n }\n\n addColumn(column, values, colIndex) {\n // Add a new column, including column defn and values\n // Inserts at colNumber or adds to the right\n this.cacheState();\n\n if (colIndex === undefined) {\n this.table.columns.push(column);\n this.table.rows.forEach((row, i) => {\n row.push(values[i]);\n });\n } else {\n this.table.columns.splice(colIndex, 0, column);\n this.table.rows.forEach((row, i) => {\n row.splice(colIndex, 0, values[i]);\n });\n }\n }\n\n removeColumns(colIndex, count = 1) {\n // Remove a column with data\n this.cacheState();\n\n this.table.columns.splice(colIndex, count);\n this.table.rows.forEach(row => {\n row.splice(colIndex, count);\n });\n }\n\n _assign(target, prop, value) {\n this.cacheState();\n target[prop] = value;\n }\n\n /* eslint-disable lines-between-class-members */\n get ref() {\n return this.table.ref;\n }\n set ref(value) {\n this._assign(this.table, 'ref', value);\n }\n\n get name() {\n return this.table.name;\n }\n set name(value) {\n this.table.name = value;\n }\n\n get displayName() {\n return this.table.displyName || this.table.name;\n }\n set displayNamename(value) {\n this.table.displayName = value;\n }\n\n get headerRow() {\n return this.table.headerRow;\n }\n set headerRow(value) {\n this._assign(this.table, 'headerRow', value);\n }\n\n get totalsRow() {\n return this.table.totalsRow;\n }\n set totalsRow(value) {\n this._assign(this.table, 'totalsRow', value);\n }\n\n get theme() {\n return this.table.style.name;\n }\n set theme(value) {\n this.table.style.name = value;\n }\n\n get showFirstColumn() {\n return this.table.style.showFirstColumn;\n }\n set showFirstColumn(value) {\n this.table.style.showFirstColumn = value;\n }\n\n get showLastColumn() {\n return this.table.style.showLastColumn;\n }\n set showLastColumn(value) {\n this.table.style.showLastColumn = value;\n }\n\n get showRowStripes() {\n return this.table.style.showRowStripes;\n }\n set showRowStripes(value) {\n this.table.style.showRowStripes = value;\n }\n\n get showColumnStripes() {\n return this.table.style.showColumnStripes;\n }\n set showColumnStripes(value) {\n this.table.style.showColumnStripes = value;\n }\n /* eslint-enable lines-between-class-members */\n}\n\nmodule.exports = Table;\n"],"mappings":";;AAAA;AACA,MAAMA,QAAQ,GAAGC,OAAO,CAAC,oBAAoB,CAAC;;AAE9C;AACA;AACA;AACA,MAAMC,cAAc,GAAG,uDAAuD;AAE9E,SAASC,e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K,CAACsF,eAAe,GAAGzF,KAAK;EAC1C;EAEA,IAAI0F,cAAcA,CAAA,EAAG;IACnB,OAAO,IAAI,CAAC9F,KAAK,CAACO,KAAK,CAACuF,cAAc;EACxC;EACA,IAAIA,cAAcA,CAAC1F,KAAK,EAAE;IACxB,IAAI,CAACJ,KAAK,CAACO,KAAK,CAACuF,cAAc,GAAG1F,KAAK;EACzC;EAEA,IAAI2F,cAAcA,CAAA,EAAG;IACnB,OAAO,IAAI,CAAC/F,KAAK,CAACO,KAAK,CAACwF,cAAc;EACxC;EACA,IAAIA,cAAcA,CAAC3F,KAAK,EAAE;IACxB,IAAI,CAACJ,KAAK,CAACO,KAAK,CAACwF,cAAc,GAAG3F,KAAK;EACzC;EAEA,IAAI4F,iBAAiBA,CAAA,EAAG;IACtB,OAAO,IAAI,CAAChG,KAAK,CAACO,KAAK,CAACyF,iBAAiB;EAC3C;EACA,IAAIA,iBAAiBA,CAAC5F,KAAK,EAAE;IAC3B,IAAI,CAACJ,KAAK,CAACO,KAAK,CAACyF,iBAAiB,GAAG5F,KAAK;EAC5C;EACA;AACF;AAEA6F,MAAM,CAACC,OAAO,GAAGtF,KAAK","ignoreList":[]}
|
|
@@ -628,12 +628,18 @@ class Worksheet {
|
|
|
628
628
|
this._mergeCellsInternal(dimensions, true);
|
|
629
629
|
}
|
|
630
630
|
_mergeCellsInternal(dimensions, ignoreStyle) {
|
|
631
|
-
// check cells aren't already merged
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
631
|
+
// check cells aren't already merged. Any existing merge that intersects the range has a
|
|
632
|
+
// cell inside it that is either a merged (slave) cell or a master indexed in this._merges,
|
|
633
|
+
// so this is O(cells in range) rather than O(existing merges).
|
|
634
|
+
// Check everything before changing anything so a rejected merge leaves the sheet untouched.
|
|
635
|
+
for (let i = dimensions.top; i <= dimensions.bottom; i++) {
|
|
636
|
+
for (let j = dimensions.left; j <= dimensions.right; j++) {
|
|
637
|
+
const cell = this.findCell(i, j);
|
|
638
|
+
if (cell && cell.type === Enums.ValueType.Merge || this._merges[colCache.encodeAddress(i, j)]) {
|
|
639
|
+
throw new Error('Cannot merge already merged cells');
|
|
640
|
+
}
|
|
635
641
|
}
|
|
636
|
-
}
|
|
642
|
+
}
|
|
637
643
|
|
|
638
644
|
// apply merge
|
|
639
645
|
const master = this.getCell(dimensions.top, dimensions.left);
|
|
@@ -928,7 +934,7 @@ Please leave feedback at https://github.com/exceljs/exceljs/discussions/2575`);
|
|
|
928
934
|
this._media = value.media.map(medium => new Image(this, medium));
|
|
929
935
|
this.sheetProtection = value.sheetProtection;
|
|
930
936
|
this.tables = value.tables.reduce((tables, table) => {
|
|
931
|
-
const t = new Table();
|
|
937
|
+
const t = new Table(this);
|
|
932
938
|
t.model = table;
|
|
933
939
|
tables[table.name] = t;
|
|
934
940
|
return tables;
|