From 8ec8baa5c68c45fb6de14aa0b7d24928d131d1c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=40Siemienik=20Pawe=C5=82?= Date: Mon, 28 Sep 2020 22:53:31 +0200 Subject: [PATCH] change max-len value, lint:fix --- .eslintrc | 2 +- .prettier | 2 +- benchmark.js | 34 ++++- excel.js | 4 +- lib/csv/csv.js | 11 +- lib/csv/stream-converter.js | 6 +- lib/doc/anchor.js | 8 +- lib/doc/cell.js | 7 +- lib/doc/column.js | 11 +- lib/doc/defined-names.js | 8 +- lib/doc/range.js | 7 +- lib/doc/row.js | 4 +- lib/doc/workbook.js | 13 +- lib/doc/worksheet.js | 28 +++- lib/stream/xlsx/sheet-rels-writer.js | 4 +- lib/stream/xlsx/workbook-reader.js | 14 +- lib/stream/xlsx/workbook-writer.js | 24 +++- lib/stream/xlsx/worksheet-reader.js | 5 +- lib/stream/xlsx/worksheet-writer.js | 6 +- lib/utils/cell-matrix.js | 4 +- lib/utils/col-cache.js | 42 +++++- lib/utils/shared-formula.js | 49 +++---- lib/utils/under-dash.js | 7 +- lib/utils/utils.js | 4 +- lib/xlsx/defaultnumformats.js | 126 +++++++++++++++--- lib/xlsx/rel-type.js | 12 +- lib/xlsx/xform/book/workbook-xform.js | 21 ++- lib/xlsx/xform/comment/vml-anchor-xform.js | 4 +- .../xform/comment/vml-client-data-xform.js | 6 +- lib/xlsx/xform/comment/vml-notes-xform.js | 7 +- lib/xlsx/xform/comment/vml-shape-xform.js | 6 +- lib/xlsx/xform/core/content-types-xform.js | 33 ++++- lib/xlsx/xform/core/core-xform.js | 12 +- lib/xlsx/xform/sheet/cell-xform.js | 8 +- .../xform/sheet/cf-ext/databar-ext-xform.js | 28 +++- .../sheet/cf/conditional-formattings-xform.js | 5 +- lib/xlsx/xform/sheet/col-xform.js | 12 +- .../xform/sheet/outline-properties-xform.js | 8 +- lib/xlsx/xform/sheet/row-xform.js | 11 +- lib/xlsx/xform/sheet/sheet-view-xform.js | 5 +- lib/xlsx/xform/sheet/worksheet-xform.js | 29 +++- lib/xlsx/xform/strings/text-xform.js | 4 +- lib/xlsx/xform/style/alignment-xform.js | 28 +++- lib/xlsx/xform/style/font-xform.js | 5 +- lib/xlsx/xform/style/styles-xform.js | 45 +++++-- lib/xlsx/xlsx.js | 15 ++- 46 files changed, 585 insertions(+), 149 deletions(-) diff --git a/.eslintrc b/.eslintrc index 9342c97f5..69ebb7529 100644 --- a/.eslintrc +++ b/.eslintrc @@ -19,7 +19,7 @@ "default-case": ["off"], "func-names": ["off", "never"], "global-require": ["off"], - "max-len": ["error", {"code": 160, "ignoreComments": true, "ignoreStrings": true}], + "max-len": ["error", {"code": 100, "ignoreComments": true, "ignoreStrings": true}], "no-console": ["error", { "allow": ["warn"] }], "no-continue": ["off"], "no-mixed-operators": ["error", {"allowSamePrecedence": true}], diff --git a/.prettier b/.prettier index dc9121c80..808c4a5ee 100644 --- a/.prettier +++ b/.prettier @@ -1,6 +1,6 @@ { "bracketSpacing": false, - "printWidth": 160, + "printWidth": 100, "trailingComma": "all", "bracketSpacing": true, "arrowParens": "avoid" diff --git a/benchmark.js b/benchmark.js index ca698f02d..9070a0013 100644 --- a/benchmark.js +++ b/benchmark.js @@ -8,7 +8,9 @@ const runs = 3; await runProfiling('huge xlsx file streams', () => { return new Promise((resolve, reject) => { // Data taken from http://eforexcel.com/wp/downloads-18-sample-csv-files-data-sets-for-testing-sales/ - const workbookReader = new ExcelJS.stream.xlsx.WorkbookReader('./spec/integration/data/huge.xlsx'); + const workbookReader = new ExcelJS.stream.xlsx.WorkbookReader( + './spec/integration/data/huge.xlsx' + ); workbookReader.read(); let worksheetCount = 0; @@ -32,7 +34,9 @@ const runs = 3; await runProfiling('huge xlsx file async iteration', async () => { // Data taken from http://eforexcel.com/wp/downloads-18-sample-csv-files-data-sets-for-testing-sales/ - const workbookReader = new ExcelJS.stream.xlsx.WorkbookReader('spec/integration/data/huge.xlsx'); + const workbookReader = new ExcelJS.stream.xlsx.WorkbookReader( + 'spec/integration/data/huge.xlsx' + ); let worksheetCount = 0; let rowCount = 0; for await (const worksheetReader of workbookReader) { @@ -55,13 +59,21 @@ const runs = 3; async function runProfiling(name, run) { console.log(''); console.log('####################################################'); - console.log(`WARMUP: Current memory usage: ${currentMemoryUsage({runGarbageCollector: true})} MB`); + console.log( + `WARMUP: Current memory usage: ${currentMemoryUsage({runGarbageCollector: true})} MB` + ); console.log(`WARMUP: ${name} profiling started`); const warmupStartTime = Date.now(); await run(); console.log(`WARMUP: ${name} profiling finished in ${Date.now() - warmupStartTime}ms`); - console.log(`WARMUP: Current memory usage (before GC): ${currentMemoryUsage({runGarbageCollector: false})} MB`); - console.log(`WARMUP: Current memory usage (after GC): ${currentMemoryUsage({runGarbageCollector: true})} MB`); + console.log( + `WARMUP: Current memory usage (before GC): ${currentMemoryUsage({ + runGarbageCollector: false, + })} MB` + ); + console.log( + `WARMUP: Current memory usage (after GC): ${currentMemoryUsage({runGarbageCollector: true})} MB` + ); for (let i = 1; i <= runs; i += 1) { console.log(''); @@ -70,8 +82,16 @@ async function runProfiling(name, run) { const startTime = Date.now(); await run(); // eslint-disable-line no-await-in-loop console.log(`RUN ${i}: ${name} profiling finished in ${Date.now() - startTime}ms`); - console.log(`RUN ${i}: Current memory usage (before GC): ${currentMemoryUsage({runGarbageCollector: false})} MB`); - console.log(`RUN ${i}: Current memory usage (after GC): ${currentMemoryUsage({runGarbageCollector: true})} MB`); + console.log( + `RUN ${i}: Current memory usage (before GC): ${currentMemoryUsage({ + runGarbageCollector: false, + })} MB` + ); + console.log( + `RUN ${i}: Current memory usage (after GC): ${currentMemoryUsage({ + runGarbageCollector: true, + })} MB` + ); } } diff --git a/excel.js b/excel.js index 4524877bb..acbb71bb8 100644 --- a/excel.js +++ b/excel.js @@ -5,7 +5,9 @@ */ if (parseInt(process.versions.node.split('.')[0], 10) < 10) { - throw new Error('For node versions older than 10, please use the ES5 Import: https://github.com/exceljs/exceljs#es5-imports'); + throw new Error( + 'For node versions older than 10, please use the ES5 Import: https://github.com/exceljs/exceljs#es5-imports' + ); } module.exports = require('./lib/exceljs.nodejs.js'); diff --git a/lib/csv/csv.js b/lib/csv/csv.js index fb6c70024..74a51084b 100644 --- a/lib/csv/csv.js +++ b/lib/csv/csv.js @@ -46,7 +46,12 @@ class CSV { return new Promise((resolve, reject) => { const worksheet = this.workbook.addWorksheet(options.sheetName); - const dateFormats = options.dateFormats || ['YYYY-MM-DD[T]HH:mm:ssZ', 'YYYY-MM-DD[T]HH:mm:ss', 'MM-DD-YYYY', 'YYYY-MM-DD']; + const dateFormats = options.dateFormats || [ + 'YYYY-MM-DD[T]HH:mm:ssZ', + 'YYYY-MM-DD[T]HH:mm:ss', + 'MM-DD-YYYY', + 'YYYY-MM-DD', + ]; const map = options.map || function(datum) { @@ -130,7 +135,9 @@ class CSV { } if (value instanceof Date) { if (dateFormat) { - return dateUTC ? dayjs.utc(value).format(dateFormat) : dayjs(value).format(dateFormat); + return dateUTC + ? dayjs.utc(value).format(dateFormat) + : dayjs(value).format(dateFormat); } return dateUTC ? dayjs.utc(value).format() : dayjs(value).format(); } diff --git a/lib/csv/stream-converter.js b/lib/csv/stream-converter.js index 639aa5b7d..f7706b25a 100644 --- a/lib/csv/stream-converter.js +++ b/lib/csv/stream-converter.js @@ -80,7 +80,11 @@ class StreamConverter { this.writeStarted = true; } - this.inner.write(this.convertInwards(data), encoding ? this.innerEncoding : undefined, callback); + this.inner.write( + this.convertInwards(data), + encoding ? this.innerEncoding : undefined, + callback + ); } read() { diff --git a/lib/doc/anchor.js b/lib/doc/anchor.js index c98bef374..a1f6cda98 100644 --- a/lib/doc/anchor.js +++ b/lib/doc/anchor.js @@ -56,13 +56,17 @@ class Anchor { } get colWidth() { - return this.worksheet && this.worksheet.getColumn(this.nativeCol + 1) && this.worksheet.getColumn(this.nativeCol + 1).isCustomWidth + return this.worksheet && + this.worksheet.getColumn(this.nativeCol + 1) && + this.worksheet.getColumn(this.nativeCol + 1).isCustomWidth ? Math.floor(this.worksheet.getColumn(this.nativeCol + 1).width * 10000) : 640000; } get rowHeight() { - return this.worksheet && this.worksheet.getRow(this.nativeRow + 1) && this.worksheet.getRow(this.nativeRow + 1).height + return this.worksheet && + this.worksheet.getRow(this.nativeRow + 1) && + this.worksheet.getRow(this.nativeRow + 1).height ? Math.floor(this.worksheet.getRow(this.nativeRow + 1).height * 10000) : 180000; } diff --git a/lib/doc/cell.js b/lib/doc/cell.js index 3ae2457a8..251dded27 100644 --- a/lib/doc/cell.js +++ b/lib/doc/cell.js @@ -787,7 +787,9 @@ class FormulaValue { get dependencies() { // find all the ranges and cells mentioned in the formula const ranges = this.formula.match(/([a-zA-Z0-9]+!)?[A-Z]{1,3}\d{1,4}:[A-Z]{1,3}\d{1,4}/g); - const cells = this.formula.replace(/([a-zA-Z0-9]+!)?[A-Z]{1,3}\d{1,4}:[A-Z]{1,3}\d{1,4}/g, '').match(/([a-zA-Z0-9]+!)?[A-Z]{1,3}\d{1,4}/g); + const cells = this.formula + .replace(/([a-zA-Z0-9]+!)?[A-Z]{1,3}\d{1,4}:[A-Z]{1,3}\d{1,4}/g, '') + .match(/([a-zA-Z0-9]+!)?[A-Z]{1,3}\d{1,4}/g); return { ranges, cells, @@ -860,7 +862,8 @@ class FormulaValue { if (!this._translatedFormula && this.model.sharedFormula) { const {worksheet} = this.cell; const master = worksheet.findCell(this.model.sharedFormula); - this._translatedFormula = master && slideFormula(master.formula, master.address, this.model.address); + this._translatedFormula = + master && slideFormula(master.formula, master.address, this.model.address); } return this._translatedFormula; } diff --git a/lib/doc/column.js b/lib/doc/column.js index e5f8ceef0..f7636172c 100644 --- a/lib/doc/column.js +++ b/lib/doc/column.js @@ -122,7 +122,9 @@ class Column { } get collapsed() { - return !!(this._outlineLevel && this._outlineLevel >= this._worksheet.properties.outlineLevelCol); + return !!( + this._outlineLevel && this._outlineLevel >= this._worksheet.properties.outlineLevelCol + ); } toString() { @@ -134,7 +136,12 @@ class Column { } equivalentTo(other) { - return this.width === other.width && this.hidden === other.hidden && this.outlineLevel === other.outlineLevel && _.isEqual(this.style, other.style); + return ( + this.width === other.width && + this.hidden === other.hidden && + this.outlineLevel === other.outlineLevel && + _.isEqual(this.style, other.style) + ); } get isDefault() { diff --git a/lib/doc/defined-names.js b/lib/doc/defined-names.js index 597744207..cb3a4942f 100644 --- a/lib/doc/defined-names.js +++ b/lib/doc/defined-names.js @@ -73,7 +73,9 @@ class DefinedNames { } getNamesEx(address) { - return _.map(this.matrixMap, (matrix, name) => matrix.findCellEx(address) && name).filter(Boolean); + return _.map(this.matrixMap, (matrix, name) => matrix.findCellEx(address) && name).filter( + Boolean + ); } _explore(matrix, cell) { @@ -172,7 +174,9 @@ class DefinedNames { get model() { // To get names per cell - just iterate over all names finding cells if they exist - return _.map(this.matrixMap, (matrix, name) => this.getRanges(name, matrix)).filter(definedName => definedName.ranges.length); + return _.map(this.matrixMap, (matrix, name) => this.getRanges(name, matrix)).filter( + definedName => definedName.ranges.length + ); } set model(value) { diff --git a/lib/doc/range.js b/lib/doc/range.js index ff0ef8c00..096ebf1ed 100644 --- a/lib/doc/range.js +++ b/lib/doc/range.js @@ -237,7 +237,12 @@ class Range { containsEx(address) { if (address.sheetName && this.sheetName && address.sheetName !== this.sheetName) return false; - return address.row >= this.top && address.row <= this.bottom && address.col >= this.left && address.col <= this.right; + return ( + address.row >= this.top && + address.row <= this.bottom && + address.col >= this.left && + address.col <= this.right + ); } forEachAddress(cb) { diff --git a/lib/doc/row.js b/lib/doc/row.js index 520cc7fe9..054f52a6a 100644 --- a/lib/doc/row.js +++ b/lib/doc/row.js @@ -324,7 +324,9 @@ class Row { } get collapsed() { - return !!(this._outlineLevel && this._outlineLevel >= this._worksheet.properties.outlineLevelRow); + return !!( + this._outlineLevel && this._outlineLevel >= this._worksheet.properties.outlineLevelRow + ); } // ========================================================================= diff --git a/lib/doc/workbook.js b/lib/doc/workbook.js index 98c42c0ea..0044a7fad 100644 --- a/lib/doc/workbook.js +++ b/lib/doc/workbook.js @@ -59,7 +59,9 @@ class Workbook { if (options) { if (typeof options === 'string') { // eslint-disable-next-line no-console - console.trace('tabColor argument is now deprecated. Please use workbook.addWorksheet(name, {properties: { tabColor: { argb: "rbg value" } }'); + console.trace( + 'tabColor argument is now deprecated. Please use workbook.addWorksheet(name, {properties: { tabColor: { argb: "rbg value" } }' + ); options = { properties: { tabColor: {argb: options}, @@ -67,7 +69,9 @@ class Workbook { }; } else if (options.argb || options.theme || options.indexed) { // eslint-disable-next-line no-console - console.trace('tabColor argument is now deprecated. Please use workbook.addWorksheet(name, {properties: { tabColor: { ... } }'); + console.trace( + 'tabColor argument is now deprecated. Please use workbook.addWorksheet(name, {properties: { tabColor: { ... } }' + ); options = { properties: { tabColor: options, @@ -76,7 +80,10 @@ class Workbook { } } - const lastOrderNo = this._worksheets.reduce((acc, ws) => ((ws && ws.orderNo) > acc ? ws.orderNo : acc), 0); + const lastOrderNo = this._worksheets.reduce( + (acc, ws) => ((ws && ws.orderNo) > acc ? ws.orderNo : acc), + 0 + ); const worksheetOptions = Object.assign({}, options, { id, name, diff --git a/lib/doc/worksheet.js b/lib/doc/worksheet.js index b1ca37852..3bcfb377b 100644 --- a/lib/doc/worksheet.js +++ b/lib/doc/worksheet.js @@ -68,7 +68,11 @@ class Worksheet { orientation: 'portrait', horizontalDpi: 4294967295, verticalDpi: 4294967295, - fitToPage: !!(options.pageSetup && (options.pageSetup.fitToWidth || options.pageSetup.fitToHeight) && !options.pageSetup.scale), + fitToPage: !!( + options.pageSetup && + (options.pageSetup.fitToWidth || options.pageSetup.fitToHeight) && + !options.pageSetup.scale + ), pageOrder: 'downThenOver', blackAndWhite: false, draft: false, @@ -693,13 +697,21 @@ class Worksheet { }; if (options && 'spinCount' in options) { // force spinCount to be integer >= 0 - options.spinCount = Number.isFinite(options.spinCount) ? Math.round(Math.max(0, options.spinCount)) : 100000; + options.spinCount = Number.isFinite(options.spinCount) + ? Math.round(Math.max(0, options.spinCount)) + : 100000; } if (password) { this.sheetProtection.algorithmName = 'SHA-512'; this.sheetProtection.saltValue = Encryptor.randomBytes(16).toString('base64'); - this.sheetProtection.spinCount = options && 'spinCount' in options ? options.spinCount : 100000; // allow user specified spinCount - this.sheetProtection.hashValue = Encryptor.convertPasswordToHash(password, 'SHA512', this.sheetProtection.saltValue, this.sheetProtection.spinCount); + this.sheetProtection.spinCount = + options && 'spinCount' in options ? options.spinCount : 100000; // allow user specified spinCount + this.sheetProtection.hashValue = Encryptor.convertPasswordToHash( + password, + 'SHA512', + this.sheetProtection.saltValue, + this.sheetProtection.spinCount + ); } if (options) { this.sheetProtection = Object.assign(this.sheetProtection, options); @@ -755,13 +767,17 @@ class Worksheet { // Deprecated get tabColor() { // eslint-disable-next-line no-console - console.trace('worksheet.tabColor property is now deprecated. Please use worksheet.properties.tabColor'); + console.trace( + 'worksheet.tabColor property is now deprecated. Please use worksheet.properties.tabColor' + ); return this.properties.tabColor; } set tabColor(value) { // eslint-disable-next-line no-console - console.trace('worksheet.tabColor property is now deprecated. Please use worksheet.properties.tabColor'); + console.trace( + 'worksheet.tabColor property is now deprecated. Please use worksheet.properties.tabColor' + ); this.properties.tabColor = value; } diff --git a/lib/stream/xlsx/sheet-rels-writer.js b/lib/stream/xlsx/sheet-rels-writer.js index 28fb8b92a..6ef9beaba 100644 --- a/lib/stream/xlsx/sheet-rels-writer.js +++ b/lib/stream/xlsx/sheet-rels-writer.js @@ -103,7 +103,9 @@ class SheetRelsWriter { '/>' ); } else { - this.stream.write(``); + this.stream.write( + `` + ); } return rId; diff --git a/lib/stream/xlsx/workbook-reader.js b/lib/stream/xlsx/workbook-reader.js index cbaa81e59..8e686319f 100644 --- a/lib/stream/xlsx/workbook-reader.js +++ b/lib/stream/xlsx/workbook-reader.js @@ -280,7 +280,12 @@ class WorkbookReader extends EventEmitter { *_parseWorksheet(iterator, sheetNo) { this._emitEntry({type: 'worksheet', id: sheetNo}); - const worksheetReader = new WorksheetReader({workbook: this, id: sheetNo, iterator, options: this.options}); + const worksheetReader = new WorksheetReader({ + workbook: this, + id: sheetNo, + iterator, + options: this.options, + }); if (this.options.worksheets === 'emit') { yield {eventType: 'worksheet', value: worksheetReader}; } @@ -288,7 +293,12 @@ class WorkbookReader extends EventEmitter { *_parseHyperlinks(iterator, sheetNo) { this._emitEntry({type: 'hyperlinks', id: sheetNo}); - const hyperlinksReader = new HyperlinkReader({workbook: this, id: sheetNo, iterator, options: this.options}); + const hyperlinksReader = new HyperlinkReader({ + workbook: this, + id: sheetNo, + iterator, + options: this.options, + }); if (this.options.hyperlinks === 'emit') { yield {eventType: 'hyperlinks', value: hyperlinksReader}; } diff --git a/lib/stream/xlsx/workbook-writer.js b/lib/stream/xlsx/workbook-writer.js index 6816c58d6..2d97cec88 100644 --- a/lib/stream/xlsx/workbook-writer.js +++ b/lib/stream/xlsx/workbook-writer.js @@ -99,7 +99,14 @@ class WorkbookWriter { await this.promise; await this.addMedia(); await this._commitWorksheets(); - await Promise.all([this.addContentTypes(), this.addApp(), this.addCore(), this.addSharedStrings(), this.addStyles(), this.addWorkbookRels()]); + await Promise.all([ + this.addContentTypes(), + this.addApp(), + this.addCore(), + this.addSharedStrings(), + this.addStyles(), + this.addWorkbookRels(), + ]); await this.addWorkbook(); return this._finalize(); } @@ -131,7 +138,8 @@ class WorkbookWriter { // shared string handling // in fact, it's even possible to switch it mid-sheet options = options || {}; - const useSharedStrings = options.useSharedStrings !== undefined ? options.useSharedStrings : this.useSharedStrings; + const useSharedStrings = + options.useSharedStrings !== undefined ? options.useSharedStrings : this.useSharedStrings; if (options.tabColor) { // eslint-disable-next-line no-console @@ -281,12 +289,20 @@ class WorkbookWriter { {Id: `rId${count++}`, Type: RelType.Theme, Target: 'theme/theme1.xml'}, ]; if (this.sharedStrings.count) { - relationships.push({Id: `rId${count++}`, Type: RelType.SharedStrings, Target: 'sharedStrings.xml'}); + relationships.push({ + Id: `rId${count++}`, + Type: RelType.SharedStrings, + Target: 'sharedStrings.xml', + }); } this._worksheets.forEach(worksheet => { if (worksheet) { worksheet.rId = `rId${count++}`; - relationships.push({Id: worksheet.rId, Type: RelType.Worksheet, Target: `worksheets/sheet${worksheet.id}.xml`}); + relationships.push({ + Id: worksheet.rId, + Type: RelType.Worksheet, + Target: `worksheets/sheet${worksheet.id}.xml`, + }); } }); return new Promise(resolve => { diff --git a/lib/stream/xlsx/worksheet-reader.js b/lib/stream/xlsx/worksheet-reader.js index 8ad59d3d3..ade13f426 100644 --- a/lib/stream/xlsx/worksheet-reader.js +++ b/lib/stream/xlsx/worksheet-reader.js @@ -321,7 +321,10 @@ class WorksheetReader extends EventEmitter { default: if (utils.isDateFmt(cell.numFmt)) { - cell.value = utils.excelToDate(parseFloat(c.v.text), properties.model && properties.model.date1904); + cell.value = utils.excelToDate( + parseFloat(c.v.text), + properties.model && properties.model.date1904 + ); } else { cell.value = parseFloat(c.v.text); } diff --git a/lib/stream/xlsx/worksheet-writer.js b/lib/stream/xlsx/worksheet-writer.js index 47a199c62..480b59fe8 100644 --- a/lib/stream/xlsx/worksheet-writer.js +++ b/lib/stream/xlsx/worksheet-writer.js @@ -142,7 +142,11 @@ class WorksheetWriter { orientation: 'portrait', horizontalDpi: 4294967295, verticalDpi: 4294967295, - fitToPage: !!(options.pageSetup && (options.pageSetup.fitToWidth || options.pageSetup.fitToHeight) && !options.pageSetup.scale), + fitToPage: !!( + options.pageSetup && + (options.pageSetup.fitToWidth || options.pageSetup.fitToHeight) && + !options.pageSetup.scale + ), pageOrder: 'downThenOver', blackAndWhite: false, draft: false, diff --git a/lib/utils/cell-matrix.js b/lib/utils/cell-matrix.js index 121b5141d..7c0956b76 100644 --- a/lib/utils/cell-matrix.js +++ b/lib/utils/cell-matrix.js @@ -130,7 +130,9 @@ class CellMatrix { return row[col]; } if (create) { - return (row[col] = this.template ? Object.assign(address, JSON.parse(JSON.stringify(this.template))) : address); + return (row[col] = this.template + ? Object.assign(address, JSON.parse(JSON.stringify(this.template))) + : address); } return undefined; } diff --git a/lib/utils/col-cache.js b/lib/utils/col-cache.js index 00b83e693..e6bacc187 100644 --- a/lib/utils/col-cache.js +++ b/lib/utils/col-cache.js @@ -1,7 +1,34 @@ // ========================================================================= // Column Letter to Number conversion const colCache = { - _dictionary: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'], + _dictionary: [ + 'A', + 'B', + 'C', + 'D', + 'E', + 'F', + 'G', + 'H', + 'I', + 'J', + 'K', + 'L', + 'M', + 'N', + 'O', + 'P', + 'Q', + 'R', + 'S', + 'T', + 'U', + 'V', + 'W', + 'X', + 'Y', + 'Z', + ], _l2n: {}, _n2l: [], _level(n) { @@ -179,7 +206,13 @@ const colCache = { right, sheetName, tl: {address: tl, col: left, row: top, $col$row: `$${this.n2l(left)}$${top}`, sheetName}, - br: {address: br, col: right, row: bottom, $col$row: `$${this.n2l(right)}$${bottom}`, sheetName}, + br: { + address: br, + col: right, + row: bottom, + $col$row: `$${this.n2l(right)}$${bottom}`, + sheetName, + }, dimensions: `${tl}:${br}`, }; } @@ -202,7 +235,10 @@ const colCache = { case 2: return colCache.encodeAddress(arguments[0], arguments[1]); case 4: - return `${colCache.encodeAddress(arguments[0], arguments[1])}:${colCache.encodeAddress(arguments[2], arguments[3])}`; + return `${colCache.encodeAddress(arguments[0], arguments[1])}:${colCache.encodeAddress( + arguments[2], + arguments[3] + )}`; default: throw new Error('Can only encode with 2 or 4 arguments'); } diff --git a/lib/utils/shared-formula.js b/lib/utils/shared-formula.js index ad8d70d28..0c9f241fb 100644 --- a/lib/utils/shared-formula.js +++ b/lib/utils/shared-formula.js @@ -7,33 +7,36 @@ const CRrx = /^([$])?([a-z]+)([$])?([1-9][0-9]*)$/i; function slideFormula(formula, fromCell, toCell) { const offset = colCache.decode(fromCell); const to = colCache.decode(toCell); - return formula.replace(replacementCandidateRx, (refMatch, sheet, sheetMaybe, addrPart, trailingParen) => { - if (trailingParen) { - return refMatch; - } - const match = CRrx.exec(addrPart); - if (match) { - const colDollar = match[1]; - const colStr = match[2].toUpperCase(); - const rowDollar = match[3]; - const rowStr = match[4]; - if (colStr.length > 3 || (colStr.length === 3 && colStr > 'XFD')) { - // > XFD is the highest col number in excel 2007 and beyond, so this is a named range + return formula.replace( + replacementCandidateRx, + (refMatch, sheet, sheetMaybe, addrPart, trailingParen) => { + if (trailingParen) { return refMatch; } - let col = colCache.l2n(colStr); - let row = parseInt(rowStr, 10); - if (!colDollar) { - col += to.col - offset.col; + const match = CRrx.exec(addrPart); + if (match) { + const colDollar = match[1]; + const colStr = match[2].toUpperCase(); + const rowDollar = match[3]; + const rowStr = match[4]; + if (colStr.length > 3 || (colStr.length === 3 && colStr > 'XFD')) { + // > XFD is the highest col number in excel 2007 and beyond, so this is a named range + return refMatch; + } + let col = colCache.l2n(colStr); + let row = parseInt(rowStr, 10); + if (!colDollar) { + col += to.col - offset.col; + } + if (!rowDollar) { + row += to.row - offset.row; + } + const res = (sheet || '') + (colDollar || '') + colCache.n2l(col) + (rowDollar || '') + row; + return res; } - if (!rowDollar) { - row += to.row - offset.row; - } - const res = (sheet || '') + (colDollar || '') + colCache.n2l(col) + (rowDollar || '') + row; - return res; + return refMatch; } - return refMatch; - }); + ); } module.exports = { diff --git a/lib/utils/under-dash.js b/lib/utils/under-dash.js index 150e1d2a3..47a12b0fb 100644 --- a/lib/utils/under-dash.js +++ b/lib/utils/under-dash.js @@ -84,7 +84,12 @@ const _ = { }, escapeHtml(html) { - return html.replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, '''); + return html + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"') + .replace(/'/g, '''); }, strcmp(a, b) { diff --git a/lib/utils/utils.js b/lib/utils/utils.js index f13669a87..9f79d632e 100644 --- a/lib/utils/utils.js +++ b/lib/utils/utils.js @@ -54,7 +54,9 @@ const utils = { return 25569 + d.getTime() / (24 * 3600 * 1000) - (date1904 ? 1462 : 0); }, excelToDate(v, date1904) { - const millisecondSinceEpoch = Math.round((v - 25569 + (date1904 ? 1462 : 0)) * 24 * 3600 * 1000); + const millisecondSinceEpoch = Math.round( + (v - 25569 + (date1904 ? 1462 : 0)) * 24 * 3600 * 1000 + ); return new Date(millisecondSinceEpoch); }, parsePath(filepath) { diff --git a/lib/xlsx/defaultnumformats.js b/lib/xlsx/defaultnumformats.js index 5839409f8..b0b7d08f0 100644 --- a/lib/xlsx/defaultnumformats.js +++ b/lib/xlsx/defaultnumformats.js @@ -19,16 +19,61 @@ module.exports = { 21: {f: 'h:mm:ss'}, 22: {f: 'm/d/yy "h":mm'}, - 27: {'zh-tw': '[$-404]e/m/d', 'zh-cn': 'yyyy"年"m"月"', 'ja-jp': '[$-411]ge.m.d', 'ko-kr': 'yyyy"年" mm"月" dd"日"'}, - 28: {'zh-tw': '[$-404]e"年"m"月"d"日"', 'zh-cn': 'm"月"d"日"', 'ja-jp': '[$-411]ggge"年"m"月"d"日"', 'ko-kr': 'mm-dd'}, - 29: {'zh-tw': '[$-404]e"年"m"月"d"日"', 'zh-cn': 'm"月"d"日"', 'ja-jp': '[$-411]ggge"年"m"月"d"日"', 'ko-kr': 'mm-dd'}, + 27: { + 'zh-tw': '[$-404]e/m/d', + 'zh-cn': 'yyyy"年"m"月"', + 'ja-jp': '[$-411]ge.m.d', + 'ko-kr': 'yyyy"年" mm"月" dd"日"', + }, + 28: { + 'zh-tw': '[$-404]e"年"m"月"d"日"', + 'zh-cn': 'm"月"d"日"', + 'ja-jp': '[$-411]ggge"年"m"月"d"日"', + 'ko-kr': 'mm-dd', + }, + 29: { + 'zh-tw': '[$-404]e"年"m"月"d"日"', + 'zh-cn': 'm"月"d"日"', + 'ja-jp': '[$-411]ggge"年"m"月"d"日"', + 'ko-kr': 'mm-dd', + }, 30: {'zh-tw': 'm/d/yy ', 'zh-cn': 'm-d-yy', 'ja-jp': 'm/d/yy', 'ko-kr': 'mm-dd-yy'}, - 31: {'zh-tw': 'yyyy"年"m"月"d"日"', 'zh-cn': 'yyyy"年"m"月"d"日"', 'ja-jp': 'yyyy"年"m"月"d"日"', 'ko-kr': 'yyyy"년" mm"월" dd"일"'}, - 32: {'zh-tw': 'hh"時"mm"分"', 'zh-cn': 'h"时"mm"分"', 'ja-jp': 'h"時"mm"分"', 'ko-kr': 'h"시" mm"분"'}, - 33: {'zh-tw': 'hh"時"mm"分"ss"秒"', 'zh-cn': 'h"时"mm"分"ss"秒"', 'ja-jp': 'h"時"mm"分"ss"秒"', 'ko-kr': 'h"시" mm"분" ss"초"'}, - 34: {'zh-tw': '上午/下午 hh"時"mm"分"', 'zh-cn': '上午/下午 h"时"mm"分"', 'ja-jp': 'yyyy"年"m"月"', 'ko-kr': 'yyyy-mm-dd'}, - 35: {'zh-tw': '上午/下午 hh"時"mm"分"ss"秒"', 'zh-cn': '上午/下午 h"时"mm"分"ss"秒"', 'ja-jp': 'm"月"d"日"', 'ko-kr': 'yyyy-mm-dd'}, - 36: {'zh-tw': '[$-404]e/m/d', 'zh-cn': 'yyyy"年"m"月"', 'ja-jp': '[$-411]ge.m.d', 'ko-kr': 'yyyy"年" mm"月" dd"日"'}, + 31: { + 'zh-tw': 'yyyy"年"m"月"d"日"', + 'zh-cn': 'yyyy"年"m"月"d"日"', + 'ja-jp': 'yyyy"年"m"月"d"日"', + 'ko-kr': 'yyyy"년" mm"월" dd"일"', + }, + 32: { + 'zh-tw': 'hh"時"mm"分"', + 'zh-cn': 'h"时"mm"分"', + 'ja-jp': 'h"時"mm"分"', + 'ko-kr': 'h"시" mm"분"', + }, + 33: { + 'zh-tw': 'hh"時"mm"分"ss"秒"', + 'zh-cn': 'h"时"mm"分"ss"秒"', + 'ja-jp': 'h"時"mm"分"ss"秒"', + 'ko-kr': 'h"시" mm"분" ss"초"', + }, + 34: { + 'zh-tw': '上午/下午 hh"時"mm"分"', + 'zh-cn': '上午/下午 h"时"mm"分"', + 'ja-jp': 'yyyy"年"m"月"', + 'ko-kr': 'yyyy-mm-dd', + }, + 35: { + 'zh-tw': '上午/下午 hh"時"mm"分"ss"秒"', + 'zh-cn': '上午/下午 h"时"mm"分"ss"秒"', + 'ja-jp': 'm"月"d"日"', + 'ko-kr': 'yyyy-mm-dd', + }, + 36: { + 'zh-tw': '[$-404]e/m/d', + 'zh-cn': 'yyyy"年"m"月"', + 'ja-jp': '[$-411]ge.m.d', + 'ko-kr': 'yyyy"年" mm"月" dd"日"', + }, 37: {f: '#,##0 ;(#,##0)'}, 38: {f: '#,##0 ;[Red](#,##0)'}, @@ -40,15 +85,60 @@ module.exports = { 48: {f: '##0.0E+0'}, 49: {f: '@'}, - 50: {'zh-tw': '[$-404]e/m/d', 'zh-cn': 'yyyy"年"m"月"', 'ja-jp': '[$-411]ge.m.d', 'ko-kr': 'yyyy"年" mm"月" dd"日"'}, - 51: {'zh-tw': '[$-404]e"年"m"月"d"日"', 'zh-cn': 'm"月"d"日"', 'ja-jp': '[$-411]ggge"年"m"月"d"日"', 'ko-kr': 'mm-dd'}, - 52: {'zh-tw': '上午/下午 hh"時"mm"分"', 'zh-cn': 'yyyy"年"m"月"', 'ja-jp': 'yyyy"年"m"月"', 'ko-kr': 'yyyy-mm-dd'}, - 53: {'zh-tw': '上午/下午 hh"時"mm"分"ss"秒"', 'zh-cn': 'm"月"d"日"', 'ja-jp': 'm"月"d"日"', 'ko-kr': 'yyyy-mm-dd'}, - 54: {'zh-tw': '[$-404]e"年"m"月"d"日"', 'zh-cn': 'm"月"d"日"', 'ja-jp': '[$-411]ggge"年"m"月"d"日"', 'ko-kr': 'mm-dd'}, - 55: {'zh-tw': '上午/下午 hh"時"mm"分"', 'zh-cn': '上午/下午 h"时"mm"分"', 'ja-jp': 'yyyy"年"m"月"', 'ko-kr': 'yyyy-mm-dd'}, - 56: {'zh-tw': '上午/下午 hh"時"mm"分"ss"秒"', 'zh-cn': '上午/下午 h"时"mm"分"ss"秒"', 'ja-jp': 'm"月"d"日"', 'ko-kr': 'yyyy-mm-dd'}, - 57: {'zh-tw': '[$-404]e/m/d', 'zh-cn': 'yyyy"年"m"月"', 'ja-jp': '[$-411]ge.m.d', 'ko-kr': 'yyyy"年" mm"月" dd"日"'}, - 58: {'zh-tw': '[$-404]e"年"m"月"d"日"', 'zh-cn': 'm"月"d"日"', 'ja-jp': '[$-411]ggge"年"m"月"d"日"', 'ko-kr': 'mm-dd'}, + 50: { + 'zh-tw': '[$-404]e/m/d', + 'zh-cn': 'yyyy"年"m"月"', + 'ja-jp': '[$-411]ge.m.d', + 'ko-kr': 'yyyy"年" mm"月" dd"日"', + }, + 51: { + 'zh-tw': '[$-404]e"年"m"月"d"日"', + 'zh-cn': 'm"月"d"日"', + 'ja-jp': '[$-411]ggge"年"m"月"d"日"', + 'ko-kr': 'mm-dd', + }, + 52: { + 'zh-tw': '上午/下午 hh"時"mm"分"', + 'zh-cn': 'yyyy"年"m"月"', + 'ja-jp': 'yyyy"年"m"月"', + 'ko-kr': 'yyyy-mm-dd', + }, + 53: { + 'zh-tw': '上午/下午 hh"時"mm"分"ss"秒"', + 'zh-cn': 'm"月"d"日"', + 'ja-jp': 'm"月"d"日"', + 'ko-kr': 'yyyy-mm-dd', + }, + 54: { + 'zh-tw': '[$-404]e"年"m"月"d"日"', + 'zh-cn': 'm"月"d"日"', + 'ja-jp': '[$-411]ggge"年"m"月"d"日"', + 'ko-kr': 'mm-dd', + }, + 55: { + 'zh-tw': '上午/下午 hh"時"mm"分"', + 'zh-cn': '上午/下午 h"时"mm"分"', + 'ja-jp': 'yyyy"年"m"月"', + 'ko-kr': 'yyyy-mm-dd', + }, + 56: { + 'zh-tw': '上午/下午 hh"時"mm"分"ss"秒"', + 'zh-cn': '上午/下午 h"时"mm"分"ss"秒"', + 'ja-jp': 'm"月"d"日"', + 'ko-kr': 'yyyy-mm-dd', + }, + 57: { + 'zh-tw': '[$-404]e/m/d', + 'zh-cn': 'yyyy"年"m"月"', + 'ja-jp': '[$-411]ge.m.d', + 'ko-kr': 'yyyy"年" mm"月" dd"日"', + }, + 58: { + 'zh-tw': '[$-404]e"年"m"月"d"日"', + 'zh-cn': 'm"月"d"日"', + 'ja-jp': '[$-411]ggge"年"m"月"d"日"', + 'ko-kr': 'mm-dd', + }, 59: {'th-th': 't0'}, 60: {'th-th': 't0.00'}, diff --git a/lib/xlsx/rel-type.js b/lib/xlsx/rel-type.js index 611cd3a98..7cd0a3d05 100644 --- a/lib/xlsx/rel-type.js +++ b/lib/xlsx/rel-type.js @@ -1,16 +1,20 @@ 'use strict'; module.exports = { - OfficeDocument: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument', + OfficeDocument: + 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument', Worksheet: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet', CalcChain: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/calcChain', - SharedStrings: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings', + SharedStrings: + 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings', Styles: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles', Theme: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme', Hyperlink: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink', Image: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image', - CoreProperties: 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties', - ExtenderProperties: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties', + CoreProperties: + 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties', + ExtenderProperties: + 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties', Comments: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments', VmlDrawing: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing', Table: 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/table', diff --git a/lib/xlsx/xform/book/workbook-xform.js b/lib/xlsx/xform/book/workbook-xform.js index 2047d72c8..5c10a5857 100644 --- a/lib/xlsx/xform/book/workbook-xform.js +++ b/lib/xlsx/xform/book/workbook-xform.js @@ -19,9 +19,17 @@ class WorkbookXform extends BaseXform { this.map = { fileVersion: WorkbookXform.STATIC_XFORMS.fileVersion, workbookPr: new WorkbookPropertiesXform(), - bookViews: new ListXform({tag: 'bookViews', count: false, childXform: new WorkbookViewXform()}), + bookViews: new ListXform({ + tag: 'bookViews', + count: false, + childXform: new WorkbookViewXform(), + }), sheets: new ListXform({tag: 'sheets', count: false, childXform: new SheetXform()}), - definedNames: new ListXform({tag: 'definedNames', count: false, childXform: new DefinedNameXform()}), + definedNames: new ListXform({ + tag: 'definedNames', + count: false, + childXform: new DefinedNameXform(), + }), calcPr: new WorkbookCalcPropertiesXform(), }; } @@ -45,7 +53,10 @@ class WorkbookXform extends BaseXform { }); } - if (sheet.pageSetup && (sheet.pageSetup.printTitlesRow || sheet.pageSetup.printTitlesColumn)) { + if ( + sheet.pageSetup && + (sheet.pageSetup.printTitlesRow || sheet.pageSetup.printTitlesColumn) + ) { const ranges = []; if (sheet.pageSetup.printTitlesColumn) { @@ -183,7 +194,9 @@ class WorkbookXform extends BaseXform { worksheet.pageSetup = {}; } const range = colCache.decodeEx(definedName.ranges[0]); - worksheet.pageSetup.printArea = worksheet.pageSetup.printArea ? `${worksheet.pageSetup.printArea}&&${range.dimensions}` : range.dimensions; + worksheet.pageSetup.printArea = worksheet.pageSetup.printArea + ? `${worksheet.pageSetup.printArea}&&${range.dimensions}` + : range.dimensions; } } else if (definedName.name === '_xlnm.Print_Titles') { worksheet = worksheets[definedName.localSheetId]; diff --git a/lib/xlsx/xform/comment/vml-anchor-xform.js b/lib/xlsx/xform/comment/vml-anchor-xform.js index 1ed68a02c..3e00136e0 100644 --- a/lib/xlsx/xform/comment/vml-anchor-xform.js +++ b/lib/xlsx/xform/comment/vml-anchor-xform.js @@ -31,7 +31,9 @@ class VmlAnchorXform extends BaseXform { } render(xmlStream, model) { - const rect = model.anchor ? this.getAnchorRect(model.anchor) : this.getDefaultRect(model.refAddress); + const rect = model.anchor + ? this.getAnchorRect(model.anchor) + : this.getDefaultRect(model.refAddress); xmlStream.leafNode('x:Anchor', null, rect.join(', ')); } diff --git a/lib/xlsx/xform/comment/vml-client-data-xform.js b/lib/xlsx/xform/comment/vml-client-data-xform.js index 7fc24d353..f09a3c7fd 100644 --- a/lib/xlsx/xform/comment/vml-client-data-xform.js +++ b/lib/xlsx/xform/comment/vml-client-data-xform.js @@ -79,7 +79,11 @@ class VmlClientDataXform extends BaseXform { } normalizeModel() { - const position = Object.assign({}, this.map['x:MoveWithCells'].model, this.map['x:SizeWithCells'].model); + const position = Object.assign( + {}, + this.map['x:MoveWithCells'].model, + this.map['x:SizeWithCells'].model + ); const len = Object.keys(position).length; this.model.editAs = POSITION_TYPE[len]; this.model.anchor = this.map['x:Anchor'].text; diff --git a/lib/xlsx/xform/comment/vml-notes-xform.js b/lib/xlsx/xform/comment/vml-notes-xform.js index 28fe95474..4b1a2ab9c 100644 --- a/lib/xlsx/xform/comment/vml-notes-xform.js +++ b/lib/xlsx/xform/comment/vml-notes-xform.js @@ -25,7 +25,12 @@ class VmlNotesXform extends BaseXform { xmlStream.leafNode('o:idmap', {'v:ext': 'edit', data: 1}); xmlStream.closeNode(); - xmlStream.openNode('v:shapetype', {id: '_x0000_t202', coordsize: '21600,21600', 'o:spt': 202, path: 'm,l,21600r21600,l21600,xe'}); + xmlStream.openNode('v:shapetype', { + id: '_x0000_t202', + coordsize: '21600,21600', + 'o:spt': 202, + path: 'm,l,21600r21600,l21600,xe', + }); xmlStream.leafNode('v:stroke', {joinstyle: 'miter'}); xmlStream.leafNode('v:path', {gradientshapeok: 't', 'o:connecttype': 'rect'}); xmlStream.closeNode(); diff --git a/lib/xlsx/xform/comment/vml-shape-xform.js b/lib/xlsx/xform/comment/vml-shape-xform.js index a34ad3136..6eb0bfeba 100644 --- a/lib/xlsx/xform/comment/vml-shape-xform.js +++ b/lib/xlsx/xform/comment/vml-shape-xform.js @@ -71,7 +71,8 @@ class VmlShapeXform extends BaseXform { switch (name) { case this.tag: this.model.margins.inset = this.map['v:textbox'].model && this.map['v:textbox'].model.inset; - this.model.protection = this.map['x:ClientData'].model && this.map['x:ClientData'].model.protection; + this.model.protection = + this.map['x:ClientData'].model && this.map['x:ClientData'].model.protection; this.model.anchor = this.map['x:ClientData'].model && this.map['x:ClientData'].model.anchor; this.model.editAs = this.map['x:ClientData'].model && this.map['x:ClientData'].model.editAs; return false; @@ -84,7 +85,8 @@ class VmlShapeXform extends BaseXform { VmlShapeXform.V_SHAPE_ATTRIBUTES = (model, index) => ({ id: `_x0000_s${1025 + index}`, type: '#_x0000_t202', - style: 'position:absolute; margin-left:105.3pt;margin-top:10.5pt;width:97.8pt;height:59.1pt;z-index:1;visibility:hidden', + style: + 'position:absolute; margin-left:105.3pt;margin-top:10.5pt;width:97.8pt;height:59.1pt;z-index:1;visibility:hidden', fillcolor: 'infoBackground [80]', strokecolor: 'none [81]', 'o:insetmode': model.note.margins && model.note.margins.insetmode, diff --git a/lib/xlsx/xform/core/content-types-xform.js b/lib/xlsx/xform/core/content-types-xform.js index d3babcf61..2999c62aa 100644 --- a/lib/xlsx/xform/core/content-types-xform.js +++ b/lib/xlsx/xform/core/content-types-xform.js @@ -21,7 +21,10 @@ class ContentTypesXform extends BaseXform { } }); - xmlStream.leafNode('Default', {Extension: 'rels', ContentType: 'application/vnd.openxmlformats-package.relationships+xml'}); + xmlStream.leafNode('Default', { + Extension: 'rels', + ContentType: 'application/vnd.openxmlformats-package.relationships+xml', + }); xmlStream.leafNode('Default', {Extension: 'xml', ContentType: 'application/xml'}); xmlStream.leafNode('Override', { @@ -31,17 +34,27 @@ class ContentTypesXform extends BaseXform { model.worksheets.forEach(worksheet => { const name = `/xl/worksheets/sheet${worksheet.id}.xml`; - xmlStream.leafNode('Override', {PartName: name, ContentType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml'}); + xmlStream.leafNode('Override', { + PartName: name, + ContentType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml', + }); }); - xmlStream.leafNode('Override', {PartName: '/xl/theme/theme1.xml', ContentType: 'application/vnd.openxmlformats-officedocument.theme+xml'}); - xmlStream.leafNode('Override', {PartName: '/xl/styles.xml', ContentType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml'}); + xmlStream.leafNode('Override', { + PartName: '/xl/theme/theme1.xml', + ContentType: 'application/vnd.openxmlformats-officedocument.theme+xml', + }); + xmlStream.leafNode('Override', { + PartName: '/xl/styles.xml', + ContentType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml', + }); const hasSharedStrings = model.sharedStrings && model.sharedStrings.count; if (hasSharedStrings) { xmlStream.leafNode('Override', { PartName: '/xl/sharedStrings.xml', - ContentType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml', + ContentType: + 'application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml', }); } @@ -77,8 +90,14 @@ class ContentTypesXform extends BaseXform { }); } - xmlStream.leafNode('Override', {PartName: '/docProps/core.xml', ContentType: 'application/vnd.openxmlformats-package.core-properties+xml'}); - xmlStream.leafNode('Override', {PartName: '/docProps/app.xml', ContentType: 'application/vnd.openxmlformats-officedocument.extended-properties+xml'}); + xmlStream.leafNode('Override', { + PartName: '/docProps/core.xml', + ContentType: 'application/vnd.openxmlformats-package.core-properties+xml', + }); + xmlStream.leafNode('Override', { + PartName: '/docProps/app.xml', + ContentType: 'application/vnd.openxmlformats-officedocument.extended-properties+xml', + }); xmlStream.closeNode(); } diff --git a/lib/xlsx/xform/core/core-xform.js b/lib/xlsx/xform/core/core-xform.js index 1edb90df8..cedde0f77 100644 --- a/lib/xlsx/xform/core/core-xform.js +++ b/lib/xlsx/xform/core/core-xform.js @@ -23,8 +23,16 @@ class CoreXform extends BaseXform { 'cp:version': new StringXform({tag: 'cp:version'}), 'cp:contentStatus': new StringXform({tag: 'cp:contentStatus'}), 'cp:contentType': new StringXform({tag: 'cp:contentType'}), - 'dcterms:created': new DateXform({tag: 'dcterms:created', attrs: CoreXform.DateAttrs, format: CoreXform.DateFormat}), - 'dcterms:modified': new DateXform({tag: 'dcterms:modified', attrs: CoreXform.DateAttrs, format: CoreXform.DateFormat}), + 'dcterms:created': new DateXform({ + tag: 'dcterms:created', + attrs: CoreXform.DateAttrs, + format: CoreXform.DateFormat, + }), + 'dcterms:modified': new DateXform({ + tag: 'dcterms:modified', + attrs: CoreXform.DateAttrs, + format: CoreXform.DateFormat, + }), }; } diff --git a/lib/xlsx/xform/sheet/cell-xform.js b/lib/xlsx/xform/sheet/cell-xform.js index 2e78bf36c..41715695a 100644 --- a/lib/xlsx/xform/sheet/cell-xform.js +++ b/lib/xlsx/xform/sheet/cell-xform.js @@ -107,7 +107,9 @@ class CellXform extends BaseXform { } else if (model.sharedFormula) { const master = options.formulae[model.sharedFormula]; if (!master) { - throw new Error(`Shared Formula master must exist above and or left of clone for cell ${model.address}`); + throw new Error( + `Shared Formula master must exist above and or left of clone for cell ${model.address}` + ); } if (master.si === undefined) { master.shareType = 'shared'; @@ -326,7 +328,9 @@ class CellXform extends BaseXform { case 'v': case 't': if (this.model.value && this.model.value.richText) { - this.model.value.richText.text = this.model.value.richText.text ? this.model.value.richText.text + text : text; + this.model.value.richText.text = this.model.value.richText.text + ? this.model.value.richText.text + text + : text; } else { this.model.value = this.model.value ? this.model.value + text : text; } diff --git a/lib/xlsx/xform/sheet/cf-ext/databar-ext-xform.js b/lib/xlsx/xform/sheet/cf-ext/databar-ext-xform.js index 05feeb3e6..0901c5ab0 100644 --- a/lib/xlsx/xform/sheet/cf-ext/databar-ext-xform.js +++ b/lib/xlsx/xform/sheet/cf-ext/databar-ext-xform.js @@ -11,8 +11,12 @@ class DatabarExtXform extends CompositeXform { this.map = { 'x14:cfvo': (this.cfvoXform = new CfvoExtXform()), 'x14:borderColor': (this.borderColorXform = new ColorXform('x14:borderColor')), - 'x14:negativeBorderColor': (this.negativeBorderColorXform = new ColorXform('x14:negativeBorderColor')), - 'x14:negativeFillColor': (this.negativeFillColorXform = new ColorXform('x14:negativeFillColor')), + 'x14:negativeBorderColor': (this.negativeBorderColorXform = new ColorXform( + 'x14:negativeBorderColor' + )), + 'x14:negativeFillColor': (this.negativeFillColorXform = new ColorXform( + 'x14:negativeFillColor' + )), 'x14:axisColor': (this.axisColorXform = new ColorXform('x14:axisColor')), }; } @@ -33,8 +37,14 @@ class DatabarExtXform extends CompositeXform { maxLength: BaseXform.toIntAttribute(model.maxLength, 100, true), border: BaseXform.toBoolAttribute(model.border, false), gradient: BaseXform.toBoolAttribute(model.gradient, true), - negativeBarColorSameAsPositive: BaseXform.toBoolAttribute(model.negativeBarColorSameAsPositive, true), - negativeBarBorderColorSameAsPositive: BaseXform.toBoolAttribute(model.negativeBarBorderColorSameAsPositive, true), + negativeBarColorSameAsPositive: BaseXform.toBoolAttribute( + model.negativeBarColorSameAsPositive, + true + ), + negativeBarBorderColorSameAsPositive: BaseXform.toBoolAttribute( + model.negativeBarBorderColorSameAsPositive, + true + ), axisPosition: BaseXform.toAttribute(model.axisPosition, 'auto'), direction: BaseXform.toAttribute(model.direction, 'leftToRight'), }); @@ -58,8 +68,14 @@ class DatabarExtXform extends CompositeXform { maxLength: BaseXform.toIntValue(attributes.maxLength, 100), border: BaseXform.toBoolValue(attributes.border, false), gradient: BaseXform.toBoolValue(attributes.gradient, true), - negativeBarColorSameAsPositive: BaseXform.toBoolValue(attributes.negativeBarColorSameAsPositive, true), - negativeBarBorderColorSameAsPositive: BaseXform.toBoolValue(attributes.negativeBarBorderColorSameAsPositive, true), + negativeBarColorSameAsPositive: BaseXform.toBoolValue( + attributes.negativeBarColorSameAsPositive, + true + ), + negativeBarBorderColorSameAsPositive: BaseXform.toBoolValue( + attributes.negativeBarBorderColorSameAsPositive, + true + ), axisPosition: BaseXform.toStringValue(attributes.axisPosition, 'auto'), direction: BaseXform.toStringValue(attributes.direction, 'leftToRight'), }; diff --git a/lib/xlsx/xform/sheet/cf/conditional-formattings-xform.js b/lib/xlsx/xform/sheet/cf/conditional-formattings-xform.js index 11756865c..548b16f63 100644 --- a/lib/xlsx/xform/sheet/cf/conditional-formattings-xform.js +++ b/lib/xlsx/xform/sheet/cf/conditional-formattings-xform.js @@ -19,7 +19,10 @@ class ConditionalFormattingsXform extends BaseXform { prepare(model, options) { // ensure each rule has a priority value - let nextPriority = model.reduce((p, cf) => Math.max(p, ...cf.rules.map(rule => rule.priority || 0)), 1); + let nextPriority = model.reduce( + (p, cf) => Math.max(p, ...cf.rules.map(rule => rule.priority || 0)), + 1 + ); model.forEach(cf => { cf.rules.forEach(rule => { if (!rule.priority) { diff --git a/lib/xlsx/xform/sheet/col-xform.js b/lib/xlsx/xform/sheet/col-xform.js index fe87f4dc8..93003cbdf 100644 --- a/lib/xlsx/xform/sheet/col-xform.js +++ b/lib/xlsx/xform/sheet/col-xform.js @@ -43,12 +43,20 @@ class ColXform extends BaseXform { const model = (this.model = { min: parseInt(node.attributes.min || '0', 10), max: parseInt(node.attributes.max || '0', 10), - width: node.attributes.width === undefined ? undefined : parseFloat(node.attributes.width || '0'), + width: + node.attributes.width === undefined + ? undefined + : parseFloat(node.attributes.width || '0'), }); if (node.attributes.style) { model.styleId = parseInt(node.attributes.style, 10); } - if (node.attributes.hidden === true || node.attributes.hidden === 'true' || node.attributes.hidden === 1 || node.attributes.hidden === '1') { + if ( + node.attributes.hidden === true || + node.attributes.hidden === 'true' || + node.attributes.hidden === 1 || + node.attributes.hidden === '1' + ) { model.hidden = true; } if (node.attributes.bestFit) { diff --git a/lib/xlsx/xform/sheet/outline-properties-xform.js b/lib/xlsx/xform/sheet/outline-properties-xform.js index b494c2490..59de15266 100644 --- a/lib/xlsx/xform/sheet/outline-properties-xform.js +++ b/lib/xlsx/xform/sheet/outline-properties-xform.js @@ -21,8 +21,12 @@ class OutlinePropertiesXform extends BaseXform { parseOpen(node) { if (node.name === this.tag) { this.model = { - summaryBelow: isDefined(node.attributes.summaryBelow) ? Boolean(Number(node.attributes.summaryBelow)) : undefined, - summaryRight: isDefined(node.attributes.summaryRight) ? Boolean(Number(node.attributes.summaryRight)) : undefined, + summaryBelow: isDefined(node.attributes.summaryBelow) + ? Boolean(Number(node.attributes.summaryBelow)) + : undefined, + summaryRight: isDefined(node.attributes.summaryRight) + ? Boolean(Number(node.attributes.summaryRight)) + : undefined, }; return true; } diff --git a/lib/xlsx/xform/sheet/row-xform.js b/lib/xlsx/xform/sheet/row-xform.js index c278839f1..4ccb73fee 100644 --- a/lib/xlsx/xform/sheet/row-xform.js +++ b/lib/xlsx/xform/sheet/row-xform.js @@ -67,7 +67,9 @@ class RowXform extends BaseXform { } if (node.name === 'row') { this.numRowsSeen += 1; - const spans = node.attributes.spans ? node.attributes.spans.split(':').map(span => parseInt(span, 10)) : [undefined, undefined]; + const spans = node.attributes.spans + ? node.attributes.spans.split(':').map(span => parseInt(span, 10)) + : [undefined, undefined]; const model = (this.model = { number: parseInt(node.attributes.r, 10), min: spans[0], @@ -77,7 +79,12 @@ class RowXform extends BaseXform { if (node.attributes.s) { model.styleId = parseInt(node.attributes.s, 10); } - if (node.attributes.hidden === true || node.attributes.hidden === 'true' || node.attributes.hidden === 1 || node.attributes.hidden === '1') { + if ( + node.attributes.hidden === true || + node.attributes.hidden === 'true' || + node.attributes.hidden === 1 || + node.attributes.hidden === '1' + ) { model.hidden = true; } if (node.attributes.bestFit) { diff --git a/lib/xlsx/xform/sheet/sheet-view-xform.js b/lib/xlsx/xform/sheet/sheet-view-xform.js index 7e6db038d..f53fdcd1f 100644 --- a/lib/xlsx/xform/sheet/sheet-view-xform.js +++ b/lib/xlsx/xform/sheet/sheet-view-xform.js @@ -50,7 +50,10 @@ class SheetViewXform extends BaseXform { xSplit = model.xSplit || 0; ySplit = model.ySplit || 0; topLeftCell = model.topLeftCell || colCache.getAddress(ySplit + 1, xSplit + 1).address; - activePane = (model.xSplit && model.ySplit && 'bottomRight') || (model.xSplit && 'topRight') || 'bottomLeft'; + activePane = + (model.xSplit && model.ySplit && 'bottomRight') || + (model.xSplit && 'topRight') || + 'bottomLeft'; xmlStream.leafNode('pane', { xSplit: model.xSplit || undefined, diff --git a/lib/xlsx/xform/sheet/worksheet-xform.js b/lib/xlsx/xform/sheet/worksheet-xform.js index bf68ab725..4b36e37ba 100644 --- a/lib/xlsx/xform/sheet/worksheet-xform.js +++ b/lib/xlsx/xform/sheet/worksheet-xform.js @@ -96,7 +96,11 @@ class WorkSheetXform extends BaseXform { this.map = { sheetPr: new SheetPropertiesXform(), dimension: new DimensionXform(), - sheetViews: new ListXform({tag: 'sheetViews', count: false, childXform: new SheetViewXform()}), + sheetViews: new ListXform({ + tag: 'sheetViews', + count: false, + childXform: new SheetViewXform(), + }), sheetFormatPr: new SheetFormatPropertiesXform(), cols: new ListXform({tag: 'cols', count: false, childXform: new ColXform()}), sheetData: new ListXform({ @@ -109,7 +113,11 @@ class WorkSheetXform extends BaseXform { autoFilter: new AutoFilterXform(), mergeCells: new ListXform({tag: 'mergeCells', count: true, childXform: new MergeCellXform()}), rowBreaks: new RowBreaksXform(), - hyperlinks: new ListXform({tag: 'hyperlinks', count: false, childXform: new HyperlinkXform()}), + hyperlinks: new ListXform({ + tag: 'hyperlinks', + count: false, + childXform: new HyperlinkXform(), + }), pageMargins: new PageMarginsXform(), dataValidations: new DataValidationsXform(), pageSetup: new PageSetupXform(), @@ -212,7 +220,10 @@ class WorkSheetXform extends BaseXform { Target: `../drawings/${drawing.name}.xml`, }); } - let rIdImage = this.preImageId === medium.imageId ? drawingRelsHash[medium.imageId] : drawingRelsHash[drawing.rels.length]; + let rIdImage = + this.preImageId === medium.imageId + ? drawingRelsHash[medium.imageId] + : drawingRelsHash[drawing.rels.length]; if (!rIdImage) { rIdImage = nextRid(drawing.rels); drawingRelsHash[drawing.rels.length] = rIdImage; @@ -387,10 +398,18 @@ class WorkSheetXform extends BaseXform { properties.outlineProperties = this.map.sheetPr.model.outlineProperties; } const sheetProperties = { - fitToPage: (this.map.sheetPr.model && this.map.sheetPr.model.pageSetup && this.map.sheetPr.model.pageSetup.fitToPage) || false, + fitToPage: + (this.map.sheetPr.model && + this.map.sheetPr.model.pageSetup && + this.map.sheetPr.model.pageSetup.fitToPage) || + false, margins: this.map.pageMargins.model, }; - const pageSetup = Object.assign(sheetProperties, this.map.pageSetup.model, this.map.printOptions.model); + const pageSetup = Object.assign( + sheetProperties, + this.map.pageSetup.model, + this.map.printOptions.model + ); const conditionalFormattings = mergeConditionalFormattings( this.map.conditionalFormatting.model, this.map.extLst.model && this.map.extLst.model['x14:conditionalFormattings'] diff --git a/lib/xlsx/xform/strings/text-xform.js b/lib/xlsx/xform/strings/text-xform.js index 5482f21ff..7604306e1 100644 --- a/lib/xlsx/xform/strings/text-xform.js +++ b/lib/xlsx/xform/strings/text-xform.js @@ -17,7 +17,9 @@ class TextXform extends BaseXform { } get model() { - return this._text.join('').replace(/_x([0-9A-F]{4})_/g, ($0, $1) => String.fromCharCode(parseInt($1, 16))); + return this._text + .join('') + .replace(/_x([0-9A-F]{4})_/g, ($0, $1) => String.fromCharCode(parseInt($1, 16))); } parseOpen(node) { diff --git a/lib/xlsx/xform/style/alignment-xform.js b/lib/xlsx/xform/style/alignment-xform.js index a38b3daab..6cd7eb11a 100644 --- a/lib/xlsx/xform/style/alignment-xform.js +++ b/lib/xlsx/xform/style/alignment-xform.js @@ -4,7 +4,15 @@ const utils = require('../../../utils/utils'); const BaseXform = require('../base-xform'); const validation = { - horizontalValues: ['left', 'center', 'right', 'fill', 'centerContinuous', 'distributed', 'justify'].reduce((p, v) => { + horizontalValues: [ + 'left', + 'center', + 'right', + 'fill', + 'centerContinuous', + 'distributed', + 'justify', + ].reduce((p, v) => { p[v] = true; return p; }, {}), @@ -132,12 +140,24 @@ class AlignmentXform extends BaseXform { } } add(node.attributes.horizontal, 'horizontal', node.attributes.horizontal); - add(node.attributes.vertical, 'vertical', node.attributes.vertical === 'center' ? 'middle' : node.attributes.vertical); + add( + node.attributes.vertical, + 'vertical', + node.attributes.vertical === 'center' ? 'middle' : node.attributes.vertical + ); add(node.attributes.wrapText, 'wrapText', !!node.attributes.wrapText); add(node.attributes.shrinkToFit, 'shrinkToFit', !!node.attributes.shrinkToFit); add(node.attributes.indent, 'indent', parseInt(node.attributes.indent, 10)); - add(node.attributes.textRotation, 'textRotation', textRotationXform.toModel(node.attributes.textRotation)); - add(node.attributes.readingOrder, 'readingOrder', node.attributes.readingOrder === '2' ? 'rtl' : 'ltr'); + add( + node.attributes.textRotation, + 'textRotation', + textRotationXform.toModel(node.attributes.textRotation) + ); + add( + node.attributes.readingOrder, + 'readingOrder', + node.attributes.readingOrder === '2' ? 'rtl' : 'ltr' + ); this.model = valid ? model : null; } diff --git a/lib/xlsx/xform/style/font-xform.js b/lib/xlsx/xform/style/font-xform.js index 0d71f47ff..56cf006c8 100644 --- a/lib/xlsx/xform/style/font-xform.js +++ b/lib/xlsx/xform/style/font-xform.js @@ -32,7 +32,10 @@ class FontXform extends BaseXform { strike: {prop: 'strike', xform: new BooleanXform({tag: 'strike', attr: 'val'})}, sz: {prop: 'size', xform: new IntegerXform({tag: 'sz', attr: 'val'})}, }; - this.map[this.options.fontNameTag] = {prop: 'name', xform: new StringXform({tag: this.options.fontNameTag, attr: 'val'})}; + this.map[this.options.fontNameTag] = { + prop: 'name', + xform: new StringXform({tag: this.options.fontNameTag, attr: 'val'}), + }; } get tag() { diff --git a/lib/xlsx/xform/style/styles-xform.js b/lib/xlsx/xform/style/styles-xform.js index 6380c12f7..e1071c424 100644 --- a/lib/xlsx/xform/style/styles-xform.js +++ b/lib/xlsx/xform/style/styles-xform.js @@ -24,11 +24,20 @@ class StylesXform extends BaseXform { this.map = { numFmts: new ListXform({tag: 'numFmts', count: true, childXform: new NumFmtXform()}), - fonts: new ListXform({tag: 'fonts', count: true, childXform: new FontXform(), $: {'x14ac:knownFonts': 1}}), + fonts: new ListXform({ + tag: 'fonts', + count: true, + childXform: new FontXform(), + $: {'x14ac:knownFonts': 1}, + }), fills: new ListXform({tag: 'fills', count: true, childXform: new FillXform()}), borders: new ListXform({tag: 'borders', count: true, childXform: new BorderXform()}), cellStyleXfs: new ListXform({tag: 'cellStyleXfs', count: true, childXform: new StyleXform()}), - cellXfs: new ListXform({tag: 'cellXfs', count: true, childXform: new StyleXform({xfId: true})}), + cellXfs: new ListXform({ + tag: 'cellXfs', + count: true, + childXform: new StyleXform({xfId: true}), + }), dxfs: new ListXform({tag: 'dxfs', always: true, count: true, childXform: new DxfXform()}), // for style manager @@ -126,7 +135,9 @@ class StylesXform extends BaseXform { }); xmlStream.closeNode(); - this.map.cellStyleXfs.render(xmlStream, [{numFmtId: 0, fontId: 0, fillId: 0, borderId: 0, xfId: 0}]); + this.map.cellStyleXfs.render(xmlStream, [ + {numFmtId: 0, fontId: 0, fillId: 0, borderId: 0, xfId: 0}, + ]); xmlStream.openNode('cellXfs', {count: model.styles.length}); model.styles.forEach(styleXml => { @@ -139,7 +150,9 @@ class StylesXform extends BaseXform { this.map.fonts.render(xmlStream, model.fonts); this.map.fills.render(xmlStream, model.fills); this.map.borders.render(xmlStream, model.borders); - this.map.cellStyleXfs.render(xmlStream, [{numFmtId: 0, fontId: 0, fillId: 0, borderId: 0, xfId: 0}]); + this.map.cellStyleXfs.render(xmlStream, [ + {numFmtId: 0, fontId: 0, fillId: 0, borderId: 0, xfId: 0}, + ]); this.map.cellXfs.render(xmlStream, model.styles); } @@ -300,7 +313,8 @@ class StylesXform extends BaseXform { // ------------------------------------------------------- // number format if (style.numFmtId) { - const numFmt = this.index.numFmt[style.numFmtId] || NumFmtXform.getDefaultFmtCode(style.numFmtId); + const numFmt = + this.index.numFmt[style.numFmtId] || NumFmtXform.getDefaultFmtCode(style.numFmtId); if (numFmt) { model.numFmt = numFmt; } @@ -419,20 +433,33 @@ StylesXform.STYLESHEET_ATTRIBUTES = { 'xmlns:x16r2': 'http://schemas.microsoft.com/office/spreadsheetml/2015/02/main', }; StylesXform.STATIC_XFORMS = { - cellStyles: new StaticXform({tag: 'cellStyles', $: {count: 1}, c: [{tag: 'cellStyle', $: {name: 'Normal', xfId: 0, builtinId: 0}}]}), + cellStyles: new StaticXform({ + tag: 'cellStyles', + $: {count: 1}, + c: [{tag: 'cellStyle', $: {name: 'Normal', xfId: 0, builtinId: 0}}], + }), dxfs: new StaticXform({tag: 'dxfs', $: {count: 0}}), - tableStyles: new StaticXform({tag: 'tableStyles', $: {count: 0, defaultTableStyle: 'TableStyleMedium2', defaultPivotStyle: 'PivotStyleLight16'}}), + tableStyles: new StaticXform({ + tag: 'tableStyles', + $: {count: 0, defaultTableStyle: 'TableStyleMedium2', defaultPivotStyle: 'PivotStyleLight16'}, + }), extLst: new StaticXform({ tag: 'extLst', c: [ { tag: 'ext', - $: {uri: '{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}', 'xmlns:x14': 'http://schemas.microsoft.com/office/spreadsheetml/2009/9/main'}, + $: { + uri: '{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}', + 'xmlns:x14': 'http://schemas.microsoft.com/office/spreadsheetml/2009/9/main', + }, c: [{tag: 'x14:slicerStyles', $: {defaultSlicerStyle: 'SlicerStyleLight1'}}], }, { tag: 'ext', - $: {uri: '{9260A510-F301-46a8-8635-F512D64BE5F5}', 'xmlns:x15': 'http://schemas.microsoft.com/office/spreadsheetml/2010/11/main'}, + $: { + uri: '{9260A510-F301-46a8-8635-F512D64BE5F5}', + 'xmlns:x15': 'http://schemas.microsoft.com/office/spreadsheetml/2010/11/main', + }, c: [{tag: 'x15:timelineStyles', $: {defaultTimelineStyle: 'TimeSlicerStyleLight1'}}], }, ], diff --git a/lib/xlsx/xlsx.js b/lib/xlsx/xlsx.js index c9c9d411d..5a81b4415 100644 --- a/lib/xlsx/xlsx.js +++ b/lib/xlsx/xlsx.js @@ -495,11 +495,19 @@ class XLSX { {Id: `rId${count++}`, Type: XLSX.RelType.Theme, Target: 'theme/theme1.xml'}, ]; if (model.sharedStrings.count) { - relationships.push({Id: `rId${count++}`, Type: XLSX.RelType.SharedStrings, Target: 'sharedStrings.xml'}); + relationships.push({ + Id: `rId${count++}`, + Type: XLSX.RelType.SharedStrings, + Target: 'sharedStrings.xml', + }); } model.worksheets.forEach(worksheet => { worksheet.rId = `rId${count++}`; - relationships.push({Id: worksheet.rId, Type: XLSX.RelType.Worksheet, Target: `worksheets/sheet${worksheet.id}.xml`}); + relationships.push({ + Id: worksheet.rId, + Type: XLSX.RelType.Worksheet, + Target: `worksheets/sheet${worksheet.id}.xml`, + }); }); const xform = new RelationshipsXform(); const xml = xform.toXml(relationships); @@ -572,7 +580,8 @@ class XLSX { model.created = model.created || new Date(); model.modified = model.modified || new Date(); - model.useSharedStrings = options.useSharedStrings !== undefined ? options.useSharedStrings : true; + model.useSharedStrings = + options.useSharedStrings !== undefined ? options.useSharedStrings : true; model.useStyles = options.useStyles !== undefined ? options.useStyles : true; // Manage the shared strings