diff --git a/.eslintrc b/.eslintrc index b59db4aa1..69ebb7529 100644 --- a/.eslintrc +++ b/.eslintrc @@ -13,12 +13,13 @@ "node": true }, "rules": { + "arrow-parens": ["error", "as-needed"], "class-methods-use-this": ["off"], "comma-dangle": ["error", {"arrays": "always-multiline", "objects": "always-multiline", "imports": "always-multiline", "exports": "always-multiline", "functions": "never"}], "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 2f891b81a..470c46807 100644 --- a/.prettier +++ b/.prettier @@ -1,6 +1,7 @@ { "bracketSpacing": false, - "printWidth": 160, + "printWidth": 100, "trailingComma": "all", - "bracketSpacing": false + "bracketSpacing": false, + "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 79c99daf0..74a51084b 100644 --- a/lib/csv/csv.js +++ b/lib/csv/csv.js @@ -2,9 +2,7 @@ const fs = require('fs'); const fastCsv = require('fast-csv'); const customParseFormat = require('dayjs/plugin/customParseFormat'); const utc = require('dayjs/plugin/utc'); -const dayjs = require('dayjs') - .extend(customParseFormat) - .extend(utc); +const dayjs = require('dayjs').extend(customParseFormat).extend(utc); const StreamBuf = require('../utils/stream-buf'); const { @@ -48,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) { @@ -132,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/modelcontainer.js b/lib/doc/modelcontainer.js index b60e1a3d2..ef0fb9249 100644 --- a/lib/doc/modelcontainer.js +++ b/lib/doc/modelcontainer.js @@ -1,6 +1,6 @@ 'use strict'; -const XLSX = require('./../xlsx/xlsx'); +const XLSX = require('../xlsx/xlsx'); class ModelContainer { constructor(model) { diff --git a/lib/doc/range.js b/lib/doc/range.js index acba915b4..096ebf1ed 100644 --- a/lib/doc/range.js +++ b/lib/doc/range.js @@ -1,4 +1,4 @@ -const colCache = require('./../utils/col-cache'); +const colCache = require('../utils/col-cache'); // used by worksheet to calculate sheet dimensions class Range { @@ -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/table.js b/lib/doc/table.js index 112b2e80b..87a96d29c 100644 --- a/lib/doc/table.js +++ b/lib/doc/table.js @@ -1,5 +1,5 @@ /* eslint-disable max-classes-per-file */ -const colCache = require('./../utils/col-cache'); +const colCache = require('../utils/col-cache'); class Column { // wrapper around column model, allowing access and manipulation 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/parse-sax.js b/lib/utils/parse-sax.js index b9c830917..d3a53a497 100644 --- a/lib/utils/parse-sax.js +++ b/lib/utils/parse-sax.js @@ -1,7 +1,7 @@ const {SaxesParser} = require('saxes'); const {PassThrough} = require('readable-stream'); -module.exports = async function*(iterable) { +module.exports = async function* (iterable) { // TODO: Remove once node v8 is deprecated // Detect and upgrade old streams if (iterable.pipe && !iterable[Symbol.asyncIterator]) { 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/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/conditional-formattings-ext-xform.js b/lib/xlsx/xform/sheet/cf-ext/conditional-formattings-ext-xform.js index 1d1db23b8..77d32b118 100644 --- a/lib/xlsx/xform/sheet/cf-ext/conditional-formattings-ext-xform.js +++ b/lib/xlsx/xform/sheet/cf-ext/conditional-formattings-ext-xform.js @@ -1,50 +1,50 @@ -const CompositeXform = require('../../composite-xform'); - -const CfRuleExtXform = require('./cf-rule-ext-xform'); -const ConditionalFormattingExtXform = require('./conditional-formatting-ext-xform'); - -class ConditionalFormattingsExtXform extends CompositeXform { - constructor() { - super(); - - this.map = { - 'x14:conditionalFormatting': (this.cfXform = new ConditionalFormattingExtXform()), - }; - } - - get tag() { - return 'x14:conditionalFormattings'; - } - - hasContent(model) { - if (model.hasExtContent === undefined) { - model.hasExtContent = model.some(cf => cf.rules.some(CfRuleExtXform.isExt)); - } - return model.hasExtContent; - } - - prepare(model, options) { - model.forEach(cf => { - this.cfXform.prepare(cf, options); - }); - } - - render(xmlStream, model) { - if (this.hasContent(model)) { - xmlStream.openNode(this.tag); - model.forEach(cf => this.cfXform.render(xmlStream, cf)); - xmlStream.closeNode(); - } - } - - createNewModel() { - return []; - } - - onParserClose(name, parser) { - // model is array of conditional formatting objects - this.model.push(parser.model); - } -} - -module.exports = ConditionalFormattingsExtXform; +const CompositeXform = require('../../composite-xform'); + +const CfRuleExtXform = require('./cf-rule-ext-xform'); +const ConditionalFormattingExtXform = require('./conditional-formatting-ext-xform'); + +class ConditionalFormattingsExtXform extends CompositeXform { + constructor() { + super(); + + this.map = { + 'x14:conditionalFormatting': (this.cfXform = new ConditionalFormattingExtXform()), + }; + } + + get tag() { + return 'x14:conditionalFormattings'; + } + + hasContent(model) { + if (model.hasExtContent === undefined) { + model.hasExtContent = model.some(cf => cf.rules.some(CfRuleExtXform.isExt)); + } + return model.hasExtContent; + } + + prepare(model, options) { + model.forEach(cf => { + this.cfXform.prepare(cf, options); + }); + } + + render(xmlStream, model) { + if (this.hasContent(model)) { + xmlStream.openNode(this.tag); + model.forEach(cf => this.cfXform.render(xmlStream, cf)); + xmlStream.closeNode(); + } + } + + createNewModel() { + return []; + } + + onParserClose(name, parser) { + // model is array of conditional formatting objects + this.model.push(parser.model); + } +} + +module.exports = ConditionalFormattingsExtXform; 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 9786f9bf0..548b16f63 100644 --- a/lib/xlsx/xform/sheet/cf/conditional-formattings-xform.js +++ b/lib/xlsx/xform/sheet/cf/conditional-formattings-xform.js @@ -1,89 +1,92 @@ -const BaseXform = require('../../base-xform'); - -const ConditionalFormattingXform = require('./conditional-formatting-xform'); - -class ConditionalFormattingsXform extends BaseXform { - constructor() { - super(); - - this.cfXform = new ConditionalFormattingXform(); - } - - get tag() { - return 'conditionalFormatting'; - } - - reset() { - this.model = []; - } - - 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); - model.forEach(cf => { - cf.rules.forEach(rule => { - if (!rule.priority) { - rule.priority = nextPriority++; - } - - if (rule.style) { - rule.dxfId = options.styles.addDxfStyle(rule.style); - } - }); - }); - } - - render(xmlStream, model) { - model.forEach(cf => { - this.cfXform.render(xmlStream, cf); - }); - } - - parseOpen(node) { - if (this.parser) { - this.parser.parseOpen(node); - return true; - } - - switch (node.name) { - case 'conditionalFormatting': - this.parser = this.cfXform; - this.parser.parseOpen(node); - return true; - - default: - return false; - } - } - - parseText(text) { - if (this.parser) { - this.parser.parseText(text); - } - } - - parseClose(name) { - if (this.parser) { - if (!this.parser.parseClose(name)) { - this.model.push(this.parser.model); - this.parser = undefined; - return false; - } - return true; - } - return false; - } - - reconcile(model, options) { - model.forEach(cf => { - cf.rules.forEach(rule => { - if (rule.dxfId !== undefined) { - rule.style = options.styles.getDxfStyle(rule.dxfId); - delete rule.dxfId; - } - }); - }); - } -} - -module.exports = ConditionalFormattingsXform; +const BaseXform = require('../../base-xform'); + +const ConditionalFormattingXform = require('./conditional-formatting-xform'); + +class ConditionalFormattingsXform extends BaseXform { + constructor() { + super(); + + this.cfXform = new ConditionalFormattingXform(); + } + + get tag() { + return 'conditionalFormatting'; + } + + reset() { + this.model = []; + } + + 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 + ); + model.forEach(cf => { + cf.rules.forEach(rule => { + if (!rule.priority) { + rule.priority = nextPriority++; + } + + if (rule.style) { + rule.dxfId = options.styles.addDxfStyle(rule.style); + } + }); + }); + } + + render(xmlStream, model) { + model.forEach(cf => { + this.cfXform.render(xmlStream, cf); + }); + } + + parseOpen(node) { + if (this.parser) { + this.parser.parseOpen(node); + return true; + } + + switch (node.name) { + case 'conditionalFormatting': + this.parser = this.cfXform; + this.parser.parseOpen(node); + return true; + + default: + return false; + } + } + + parseText(text) { + if (this.parser) { + this.parser.parseText(text); + } + } + + parseClose(name) { + if (this.parser) { + if (!this.parser.parseClose(name)) { + this.model.push(this.parser.model); + this.parser = undefined; + return false; + } + return true; + } + return false; + } + + reconcile(model, options) { + model.forEach(cf => { + cf.rules.forEach(rule => { + if (rule.dxfId !== undefined) { + rule.style = options.styles.getDxfStyle(rule.dxfId); + delete rule.dxfId; + } + }); + }); + } +} + +module.exports = ConditionalFormattingsXform; 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 diff --git a/package.json b/package.json index ae555aeb2..01f45102a 100644 --- a/package.json +++ b/package.json @@ -96,23 +96,23 @@ "pageSetup" ], "dependencies": { - "archiver": "^4.0.2", + "archiver": "^5.0.0", "dayjs": "^1.8.34", "fast-csv": "^4.3.1", - "jszip": "^3.4.0", + "jszip": "^3.5.0", "readable-stream": "^3.6.0", "saxes": "^5.0.1", "tmp": "^0.2.0", "unzipper": "^0.10.11", - "uuid": "^7.0.3" + "uuid": "^8.3.0" }, "devDependencies": { "@babel/cli": "^7.10.5", "@babel/core": "^7.11.4", "@babel/preset-env": "^7.11.0", "@types/chai": "^4.2.12", - "@types/mocha": "^7.0.2", - "@types/node": "^13.13.15", + "@types/mocha": "^8.0.3", + "@types/node": "^14.11.2", "babelify": "^10.0.0", "browserify": "^16.5.2", "chai": "^4.2.0", @@ -121,8 +121,8 @@ "core-js": "^3.6.5", "dirty-chai": "^2.0.1", "eslint": "^6.5.1", - "eslint-config-airbnb-base": "^14.1.0", - "eslint-config-prettier": "^6.11.0", + "eslint-config-airbnb-base": "^14.2.0", + "eslint-config-prettier": "^6.12.0", "eslint-friendly-formatter": "^4.0.1", "eslint-plugin-import": "^2.22.0", "eslint-plugin-node": "^11.1.0", @@ -132,16 +132,16 @@ "grunt-babel": "^8.0.0", "grunt-browserify": "^5.3.0", "grunt-contrib-copy": "^1.0.0", - "grunt-contrib-jasmine": "^2.1.0", + "grunt-contrib-jasmine": "^2.2.0", "grunt-contrib-watch": "^1.1.0", "grunt-terser": "^1.0.0", - "husky": "^4.2.5", + "husky": "^4.3.0", "lint-staged": "^10.2.13", - "mocha": "^7.1.1", - "prettier-eslint": "^9.0.0", + "mocha": "^7.2.0", + "prettier-eslint": "^11.0.0", "prettier-eslint-cli": "^5.0.0", "regenerator-runtime": "^0.13.7", - "ts-node": "^8.9.0", + "ts-node": "^8.10.2", "typescript": "^3.9.7" } } diff --git a/spec/integration/issues/issue-1328-xlsx-worksheet-reader-date.spec.js b/spec/integration/issues/issue-1328-xlsx-worksheet-reader-date.spec.js index 2337fc790..acfa4da74 100644 --- a/spec/integration/issues/issue-1328-xlsx-worksheet-reader-date.spec.js +++ b/spec/integration/issues/issue-1328-xlsx-worksheet-reader-date.spec.js @@ -1,20 +1,33 @@ const ExcelJS = verquire('exceljs'); const fs = require('fs'); - describe('github issues: Date field with cache style', () => { const rows = []; - beforeEach(() => - new Promise((resolve, reject) => { - const workbookReader = new ExcelJS.stream.xlsx.WorkbookReader(fs.createReadStream('./spec/integration/data/dateIssue.xlsx'), { worksheets: 'emit', styles: 'cache', sharedStrings: 'cache', hyperlinks: 'ignore', entries: 'ignore' }); - workbookReader.read(); - workbookReader.on('worksheet', worksheet => worksheet.on('row', row => rows.push(row.values[1]))); - workbookReader.on('end', resolve); - workbookReader.on('error', reject); - - }) + beforeEach( + () => + new Promise((resolve, reject) => { + const workbookReader = new ExcelJS.stream.xlsx.WorkbookReader( + fs.createReadStream('./spec/integration/data/dateIssue.xlsx'), + { + worksheets: 'emit', + styles: 'cache', + sharedStrings: 'cache', + hyperlinks: 'ignore', + entries: 'ignore', + } + ); + workbookReader.read(); + workbookReader.on('worksheet', worksheet => + worksheet.on('row', row => rows.push(row.values[1])) + ); + workbookReader.on('end', resolve); + workbookReader.on('error', reject); + }) ); it('issue 1328 - should emit row with Date Object', () => { - expect(rows).that.deep.equals(['Date', new Date('2020-11-20T00:00:00.000Z')]); + expect(rows).that.deep.equals([ + 'Date', + new Date('2020-11-20T00:00:00.000Z'), + ]); }); }); diff --git a/spec/integration/issues/issue-771-data-validation-without-type.spec.js b/spec/integration/issues/issue-771-data-validation-without-type.spec.js index a46505c16..9e48b3700 100644 --- a/spec/integration/issues/issue-771-data-validation-without-type.spec.js +++ b/spec/integration/issues/issue-771-data-validation-without-type.spec.js @@ -3,8 +3,6 @@ const ExcelJS = verquire('exceljs'); describe('github issues', () => { it('issue 771 - Issue with dataValidation without type and with formula1 or formula2', () => { const wb = new ExcelJS.Workbook(); - return wb.xlsx - .readFile('./spec/integration/data/test-issue-771.xlsx'); + return wb.xlsx.readFile('./spec/integration/data/test-issue-771.xlsx'); }); }); - diff --git a/spec/integration/pr/test-pr-1431.spec.js b/spec/integration/pr/test-pr-1431.spec.js index 631a49839..5c3708f92 100644 --- a/spec/integration/pr/test-pr-1431.spec.js +++ b/spec/integration/pr/test-pr-1431.spec.js @@ -24,13 +24,16 @@ describe('github issues', () => { await workbook.commit(); return new Promise((resolve, reject) => { - const workbookReader = new ExcelJS.stream.xlsx.WorkbookReader('./test.xlsx', { - entries: 'emit', - hyperlinks: 'cache', - sharedStrings: 'cache', - styles: 'cache', - worksheets: 'emit', - }); + const workbookReader = new ExcelJS.stream.xlsx.WorkbookReader( + './test.xlsx', + { + entries: 'emit', + hyperlinks: 'cache', + sharedStrings: 'cache', + styles: 'cache', + worksheets: 'emit', + } + ); workbookReader.on('worksheet', worksheet => worksheet.on('row', row => { diff --git a/spec/unit/doc/workbook.spec.js b/spec/unit/doc/workbook.spec.js index ff6a1d7d3..ffde48eab 100644 --- a/spec/unit/doc/workbook.spec.js +++ b/spec/unit/doc/workbook.spec.js @@ -1,4 +1,4 @@ -const simpleWorkbookModel = require('./../data/simpleWorkbook.json'); +const simpleWorkbookModel = require('../data/simpleWorkbook.json'); const testUtils = require('../../utils/index'); const Excel = verquire('exceljs'); diff --git a/spec/unit/xlsx/xform/book/defined-name-xform.spec.js b/spec/unit/xlsx/xform/book/defined-name-xform.spec.js index 07ce3296a..27a6b10ca 100644 --- a/spec/unit/xlsx/xform/book/defined-name-xform.spec.js +++ b/spec/unit/xlsx/xform/book/defined-name-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const DefinedNameXform = verquire('xlsx/xform/book/defined-name-xform'); diff --git a/spec/unit/xlsx/xform/book/workbook-calc-properties-xform.spec.js b/spec/unit/xlsx/xform/book/workbook-calc-properties-xform.spec.js index 67e772ca2..3ee15fe38 100644 --- a/spec/unit/xlsx/xform/book/workbook-calc-properties-xform.spec.js +++ b/spec/unit/xlsx/xform/book/workbook-calc-properties-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const WorkbookCalcPropertiesXform = verquire( 'xlsx/xform/book/workbook-calc-properties-xform' diff --git a/spec/unit/xlsx/xform/book/workbook-properties-xform.spec.js b/spec/unit/xlsx/xform/book/workbook-properties-xform.spec.js index 3726ffbda..9a908134f 100644 --- a/spec/unit/xlsx/xform/book/workbook-properties-xform.spec.js +++ b/spec/unit/xlsx/xform/book/workbook-properties-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const WorkbookPropertiesXform = verquire( 'xlsx/xform/book/workbook-properties-xform' diff --git a/spec/unit/xlsx/xform/book/workbook-view-xform.spec.js b/spec/unit/xlsx/xform/book/workbook-view-xform.spec.js index 268de357a..5cd4094da 100644 --- a/spec/unit/xlsx/xform/book/workbook-view-xform.spec.js +++ b/spec/unit/xlsx/xform/book/workbook-view-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const WorkbookViewXform = verquire('xlsx/xform/book/workbook-view-xform'); diff --git a/spec/unit/xlsx/xform/compy-xform.js b/spec/unit/xlsx/xform/compy-xform.js index afbd849ee..db3e98432 100644 --- a/spec/unit/xlsx/xform/compy-xform.js +++ b/spec/unit/xlsx/xform/compy-xform.js @@ -1,77 +1,77 @@ -const BaseXform = verquire('xlsx/xform/base-xform'); - -class CompyXform extends BaseXform { - constructor(options) { - super(); - - this.tag = options.tag; - this.attrs = options.attrs; - this.children = options.children; - this.map = this.children.reduce((map, child) => { - const name = child.name || child.tag; - const tag = child.tag || child.name; - map[tag] = child; - child.name = name; - child.tag = tag; - return map; - }, {}); - } - - prepare(model, options) { - this.children.forEach(child => { - child.xform.prepare(model[child.tag], options); - }); - } - - render(xmlStream, model) { - xmlStream.openNode(this.tag, this.attrs); - this.children.forEach(child => { - child.xform.render(xmlStream, model[child.name]); - }); - xmlStream.closeNode(); - } - - parseOpen(node) { - if (this.parser) { - this.parser.xform.parseOpen(node); - return true; - } - switch (node.name) { - case this.tag: - this.model = {}; - return true; - default: - this.parser = this.map[node.name]; - if (this.parser) { - this.parser.xform.parseOpen(node); - return true; - } - } - return false; - } - - parseText(text) { - if (this.parser) { - this.parser.xform.parseText(text); - } - } - - parseClose(name) { - if (this.parser) { - if (!this.parser.xform.parseClose(name)) { - this.model[this.parser.name] = this.parser.xform.model; - this.parser = undefined; - } - return true; - } - return false; - } - - reconcile(model, options) { - this.children.forEach(child => { - child.xform.prepare(model[child.tag], options); - }); - } -} - -module.exports = CompyXform; +const BaseXform = verquire('xlsx/xform/base-xform'); + +class CompyXform extends BaseXform { + constructor(options) { + super(); + + this.tag = options.tag; + this.attrs = options.attrs; + this.children = options.children; + this.map = this.children.reduce((map, child) => { + const name = child.name || child.tag; + const tag = child.tag || child.name; + map[tag] = child; + child.name = name; + child.tag = tag; + return map; + }, {}); + } + + prepare(model, options) { + this.children.forEach(child => { + child.xform.prepare(model[child.tag], options); + }); + } + + render(xmlStream, model) { + xmlStream.openNode(this.tag, this.attrs); + this.children.forEach(child => { + child.xform.render(xmlStream, model[child.name]); + }); + xmlStream.closeNode(); + } + + parseOpen(node) { + if (this.parser) { + this.parser.xform.parseOpen(node); + return true; + } + switch (node.name) { + case this.tag: + this.model = {}; + return true; + default: + this.parser = this.map[node.name]; + if (this.parser) { + this.parser.xform.parseOpen(node); + return true; + } + } + return false; + } + + parseText(text) { + if (this.parser) { + this.parser.xform.parseText(text); + } + } + + parseClose(name) { + if (this.parser) { + if (!this.parser.xform.parseClose(name)) { + this.model[this.parser.name] = this.parser.xform.model; + this.parser = undefined; + } + return true; + } + return false; + } + + reconcile(model, options) { + this.children.forEach(child => { + child.xform.prepare(model[child.tag], options); + }); + } +} + +module.exports = CompyXform; diff --git a/spec/unit/xlsx/xform/core/content-types-xform.spec.js b/spec/unit/xlsx/xform/core/content-types-xform.spec.js index 82bda44b5..29e4ea0e5 100644 --- a/spec/unit/xlsx/xform/core/content-types-xform.spec.js +++ b/spec/unit/xlsx/xform/core/content-types-xform.spec.js @@ -1,6 +1,6 @@ const fs = require('fs'); -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const ContentTypesXform = verquire('xlsx/xform/core/content-types-xform'); diff --git a/spec/unit/xlsx/xform/core/core-xform.spec.js b/spec/unit/xlsx/xform/core/core-xform.spec.js index 1f2730d40..607457aae 100644 --- a/spec/unit/xlsx/xform/core/core-xform.spec.js +++ b/spec/unit/xlsx/xform/core/core-xform.spec.js @@ -1,6 +1,6 @@ const fs = require('fs'); -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const CoreXform = verquire('xlsx/xform/core/core-xform'); diff --git a/spec/unit/xlsx/xform/core/relationships-xform.spec.js b/spec/unit/xlsx/xform/core/relationships-xform.spec.js index f624474fc..a967a6223 100644 --- a/spec/unit/xlsx/xform/core/relationships-xform.spec.js +++ b/spec/unit/xlsx/xform/core/relationships-xform.spec.js @@ -1,6 +1,6 @@ const fs = require('fs'); -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const RelationshipsXform = verquire('xlsx/xform/core/relationships-xform'); diff --git a/spec/unit/xlsx/xform/drawing/blip-fill-xform.spec.js b/spec/unit/xlsx/xform/drawing/blip-fill-xform.spec.js index ca955f516..40def1e70 100644 --- a/spec/unit/xlsx/xform/drawing/blip-fill-xform.spec.js +++ b/spec/unit/xlsx/xform/drawing/blip-fill-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const BlipFillXform = verquire('xlsx/xform/drawing/blip-fill-xform'); diff --git a/spec/unit/xlsx/xform/drawing/blip-xform.spec.js b/spec/unit/xlsx/xform/drawing/blip-xform.spec.js index 3ce8419c0..788089ca5 100644 --- a/spec/unit/xlsx/xform/drawing/blip-xform.spec.js +++ b/spec/unit/xlsx/xform/drawing/blip-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const BlipXform = verquire('xlsx/xform/drawing/blip-xform'); diff --git a/spec/unit/xlsx/xform/drawing/cell-position-xform.spec.js b/spec/unit/xlsx/xform/drawing/cell-position-xform.spec.js index d592d7429..b278d5b0c 100644 --- a/spec/unit/xlsx/xform/drawing/cell-position-xform.spec.js +++ b/spec/unit/xlsx/xform/drawing/cell-position-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const CellPositionXform = verquire('xlsx/xform/drawing/cell-position-xform'); diff --git a/spec/unit/xlsx/xform/drawing/drawing-xform.spec.js b/spec/unit/xlsx/xform/drawing/drawing-xform.spec.js index adcc73f96..c5ee02ee1 100644 --- a/spec/unit/xlsx/xform/drawing/drawing-xform.spec.js +++ b/spec/unit/xlsx/xform/drawing/drawing-xform.spec.js @@ -1,6 +1,6 @@ const fs = require('fs'); -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const DrawingXform = verquire('xlsx/xform/drawing/drawing-xform'); diff --git a/spec/unit/xlsx/xform/sheet/auto-filter-xform.spec.js b/spec/unit/xlsx/xform/sheet/auto-filter-xform.spec.js index c07cdbc7b..4fe1bd43a 100644 --- a/spec/unit/xlsx/xform/sheet/auto-filter-xform.spec.js +++ b/spec/unit/xlsx/xform/sheet/auto-filter-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const AutoFilterXform = verquire('xlsx/xform/sheet/auto-filter-xform'); diff --git a/spec/unit/xlsx/xform/sheet/cell-xform.spec.js b/spec/unit/xlsx/xform/sheet/cell-xform.spec.js index f527e947f..e5dad466c 100644 --- a/spec/unit/xlsx/xform/sheet/cell-xform.spec.js +++ b/spec/unit/xlsx/xform/sheet/cell-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const CellXform = verquire('xlsx/xform/sheet/cell-xform'); const SharedStringsXform = verquire('xlsx/xform/strings/shared-strings-xform'); diff --git a/spec/unit/xlsx/xform/sheet/col-xform.spec.js b/spec/unit/xlsx/xform/sheet/col-xform.spec.js index d81d8a0c7..403de2311 100644 --- a/spec/unit/xlsx/xform/sheet/col-xform.spec.js +++ b/spec/unit/xlsx/xform/sheet/col-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const ColXform = verquire('xlsx/xform/sheet/col-xform'); diff --git a/spec/unit/xlsx/xform/sheet/data-validations-xform.spec.js b/spec/unit/xlsx/xform/sheet/data-validations-xform.spec.js index b9b2a4b33..1887b3de3 100644 --- a/spec/unit/xlsx/xform/sheet/data-validations-xform.spec.js +++ b/spec/unit/xlsx/xform/sheet/data-validations-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const DataValidationsXform = verquire( 'xlsx/xform/sheet/data-validations-xform' diff --git a/spec/unit/xlsx/xform/sheet/dimension-xform.spec.js b/spec/unit/xlsx/xform/sheet/dimension-xform.spec.js index 30f019a47..f0dd04c89 100644 --- a/spec/unit/xlsx/xform/sheet/dimension-xform.spec.js +++ b/spec/unit/xlsx/xform/sheet/dimension-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const DimensionXform = verquire('xlsx/xform/sheet/dimension-xform'); diff --git a/spec/unit/xlsx/xform/sheet/header-footer-xform.spec.js b/spec/unit/xlsx/xform/sheet/header-footer-xform.spec.js index 042ac114c..0f643cb6d 100644 --- a/spec/unit/xlsx/xform/sheet/header-footer-xform.spec.js +++ b/spec/unit/xlsx/xform/sheet/header-footer-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const HeaderFooterXform = verquire('xlsx/xform/sheet/header-footer-xform'); diff --git a/spec/unit/xlsx/xform/sheet/hyperlink-xform.spec.js b/spec/unit/xlsx/xform/sheet/hyperlink-xform.spec.js index ab1deed3b..4292dfe9d 100644 --- a/spec/unit/xlsx/xform/sheet/hyperlink-xform.spec.js +++ b/spec/unit/xlsx/xform/sheet/hyperlink-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const HyperlinkXform = verquire('xlsx/xform/sheet/hyperlink-xform'); diff --git a/spec/unit/xlsx/xform/sheet/merge-cell-xform.spec.js b/spec/unit/xlsx/xform/sheet/merge-cell-xform.spec.js index c7ecc183e..e1b62d92e 100644 --- a/spec/unit/xlsx/xform/sheet/merge-cell-xform.spec.js +++ b/spec/unit/xlsx/xform/sheet/merge-cell-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const MergeCellXform = verquire('xlsx/xform/sheet/merge-cell-xform'); diff --git a/spec/unit/xlsx/xform/sheet/outline-properties-xform.spec.js b/spec/unit/xlsx/xform/sheet/outline-properties-xform.spec.js index a2e826f4b..34c250e7b 100644 --- a/spec/unit/xlsx/xform/sheet/outline-properties-xform.spec.js +++ b/spec/unit/xlsx/xform/sheet/outline-properties-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const OutlinePropertiesXform = verquire( 'xlsx/xform/sheet/outline-properties-xform' diff --git a/spec/unit/xlsx/xform/sheet/page-breaks-xform.spec.js b/spec/unit/xlsx/xform/sheet/page-breaks-xform.spec.js index 00f16fb7d..e85e98c8d 100644 --- a/spec/unit/xlsx/xform/sheet/page-breaks-xform.spec.js +++ b/spec/unit/xlsx/xform/sheet/page-breaks-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const PageBreaksXform = verquire('xlsx/xform/sheet/page-breaks-xform'); diff --git a/spec/unit/xlsx/xform/sheet/page-margins-xform.spec.js b/spec/unit/xlsx/xform/sheet/page-margins-xform.spec.js index 867947c3d..4f560011f 100644 --- a/spec/unit/xlsx/xform/sheet/page-margins-xform.spec.js +++ b/spec/unit/xlsx/xform/sheet/page-margins-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const PageMarginsXform = verquire('xlsx/xform/sheet/page-margins-xform'); diff --git a/spec/unit/xlsx/xform/sheet/page-setup-properties-xform.spec.js b/spec/unit/xlsx/xform/sheet/page-setup-properties-xform.spec.js index 91ea3151c..ae6de07df 100644 --- a/spec/unit/xlsx/xform/sheet/page-setup-properties-xform.spec.js +++ b/spec/unit/xlsx/xform/sheet/page-setup-properties-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const PageSetupPropertiesXform = verquire( 'xlsx/xform/sheet/page-setup-properties-xform' diff --git a/spec/unit/xlsx/xform/sheet/page-setup-xform.spec.js b/spec/unit/xlsx/xform/sheet/page-setup-xform.spec.js index 32ce20520..d4e8a6a7f 100644 --- a/spec/unit/xlsx/xform/sheet/page-setup-xform.spec.js +++ b/spec/unit/xlsx/xform/sheet/page-setup-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const PageSetupXform = verquire('xlsx/xform/sheet/page-setup-xform'); diff --git a/spec/unit/xlsx/xform/sheet/print-options-xform.spec.js b/spec/unit/xlsx/xform/sheet/print-options-xform.spec.js index 238cf75d2..8f1adf7c8 100644 --- a/spec/unit/xlsx/xform/sheet/print-options-xform.spec.js +++ b/spec/unit/xlsx/xform/sheet/print-options-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const PrintOptionsXform = verquire('xlsx/xform/sheet/print-options-xform'); diff --git a/spec/unit/xlsx/xform/sheet/row-xform.spec.js b/spec/unit/xlsx/xform/sheet/row-xform.spec.js index a96f2a7fd..9b2d9cc8a 100644 --- a/spec/unit/xlsx/xform/sheet/row-xform.spec.js +++ b/spec/unit/xlsx/xform/sheet/row-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const RowXform = verquire('xlsx/xform/sheet/row-xform'); const SharedStringsXform = verquire('xlsx/xform/strings/shared-strings-xform'); diff --git a/spec/unit/xlsx/xform/sheet/sheet-format-properties-xform.spec.js b/spec/unit/xlsx/xform/sheet/sheet-format-properties-xform.spec.js index 7cbbefd92..8e120bde6 100644 --- a/spec/unit/xlsx/xform/sheet/sheet-format-properties-xform.spec.js +++ b/spec/unit/xlsx/xform/sheet/sheet-format-properties-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const SheetFormatPropertiesXform = verquire( 'xlsx/xform/sheet/sheet-format-properties-xform' diff --git a/spec/unit/xlsx/xform/sheet/sheet-properties-xform.spec.js b/spec/unit/xlsx/xform/sheet/sheet-properties-xform.spec.js index 426491b85..dda10bbfe 100644 --- a/spec/unit/xlsx/xform/sheet/sheet-properties-xform.spec.js +++ b/spec/unit/xlsx/xform/sheet/sheet-properties-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const SheetPropertiesXform = verquire( 'xlsx/xform/sheet/sheet-properties-xform' diff --git a/spec/unit/xlsx/xform/sheet/sheet-view-xform.spec.js b/spec/unit/xlsx/xform/sheet/sheet-view-xform.spec.js index 27e5a8fae..188002f4e 100644 --- a/spec/unit/xlsx/xform/sheet/sheet-view-xform.spec.js +++ b/spec/unit/xlsx/xform/sheet/sheet-view-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const SheetViewXform = verquire('xlsx/xform/sheet/sheet-view-xform'); const ListXform = verquire('xlsx/xform/list-xform'); diff --git a/spec/unit/xlsx/xform/simple/boolean-xform.spec.js b/spec/unit/xlsx/xform/simple/boolean-xform.spec.js index ced242fb3..e9d9d7a82 100644 --- a/spec/unit/xlsx/xform/simple/boolean-xform.spec.js +++ b/spec/unit/xlsx/xform/simple/boolean-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const BooleanXform = verquire('xlsx/xform/simple/boolean-xform'); diff --git a/spec/unit/xlsx/xform/simple/date-xform.spec.js b/spec/unit/xlsx/xform/simple/date-xform.spec.js index 986934702..a5c737010 100644 --- a/spec/unit/xlsx/xform/simple/date-xform.spec.js +++ b/spec/unit/xlsx/xform/simple/date-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const DateXform = verquire('xlsx/xform/simple/date-xform'); diff --git a/spec/unit/xlsx/xform/simple/float-xform.spec.js b/spec/unit/xlsx/xform/simple/float-xform.spec.js index 4cca1a3d8..e8a5c19c0 100644 --- a/spec/unit/xlsx/xform/simple/float-xform.spec.js +++ b/spec/unit/xlsx/xform/simple/float-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const FloatXform = verquire('xlsx/xform/simple/float-xform'); diff --git a/spec/unit/xlsx/xform/simple/integer-xform.spec.js b/spec/unit/xlsx/xform/simple/integer-xform.spec.js index 83d4db447..d5e920b76 100644 --- a/spec/unit/xlsx/xform/simple/integer-xform.spec.js +++ b/spec/unit/xlsx/xform/simple/integer-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const IntegerXform = verquire('xlsx/xform/simple/integer-xform'); diff --git a/spec/unit/xlsx/xform/simple/string-xform.spec.js b/spec/unit/xlsx/xform/simple/string-xform.spec.js index 2d83c64f7..a276fffdf 100644 --- a/spec/unit/xlsx/xform/simple/string-xform.spec.js +++ b/spec/unit/xlsx/xform/simple/string-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const StringXform = verquire('xlsx/xform/simple/string-xform'); diff --git a/spec/unit/xlsx/xform/strings/phonetic-text-xform.spec.js b/spec/unit/xlsx/xform/strings/phonetic-text-xform.spec.js index a30b68e35..1077d35ac 100644 --- a/spec/unit/xlsx/xform/strings/phonetic-text-xform.spec.js +++ b/spec/unit/xlsx/xform/strings/phonetic-text-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const PhoneticTextXform = verquire('xlsx/xform/strings/phonetic-text-xform'); diff --git a/spec/unit/xlsx/xform/style/alignment-xform.spec.js b/spec/unit/xlsx/xform/style/alignment-xform.spec.js index 80e68738b..12f8d04dd 100644 --- a/spec/unit/xlsx/xform/style/alignment-xform.spec.js +++ b/spec/unit/xlsx/xform/style/alignment-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const AlignmentXform = verquire('xlsx/xform/style/alignment-xform'); diff --git a/spec/unit/xlsx/xform/style/border-xform.spec.js b/spec/unit/xlsx/xform/style/border-xform.spec.js index eb2c4da05..40f8b5162 100644 --- a/spec/unit/xlsx/xform/style/border-xform.spec.js +++ b/spec/unit/xlsx/xform/style/border-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const BorderXform = verquire('xlsx/xform/style/border-xform'); diff --git a/spec/unit/xlsx/xform/style/color-xform.spec.js b/spec/unit/xlsx/xform/style/color-xform.spec.js index 4dbde6289..445781d50 100644 --- a/spec/unit/xlsx/xform/style/color-xform.spec.js +++ b/spec/unit/xlsx/xform/style/color-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const ColorXform = verquire('xlsx/xform/style/color-xform'); diff --git a/spec/unit/xlsx/xform/style/fill-xform.spec.js b/spec/unit/xlsx/xform/style/fill-xform.spec.js index bcf7a2773..ddc92bb10 100644 --- a/spec/unit/xlsx/xform/style/fill-xform.spec.js +++ b/spec/unit/xlsx/xform/style/fill-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const FillXform = verquire('xlsx/xform/style/fill-xform'); diff --git a/spec/unit/xlsx/xform/style/font-xform.spec.js b/spec/unit/xlsx/xform/style/font-xform.spec.js index bb8dfa04f..dc6be0d6c 100644 --- a/spec/unit/xlsx/xform/style/font-xform.spec.js +++ b/spec/unit/xlsx/xform/style/font-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const FontXform = verquire('xlsx/xform/style/font-xform'); diff --git a/spec/unit/xlsx/xform/style/numfmt-xform.spec.js b/spec/unit/xlsx/xform/style/numfmt-xform.spec.js index 0964ffa36..cd2856918 100644 --- a/spec/unit/xlsx/xform/style/numfmt-xform.spec.js +++ b/spec/unit/xlsx/xform/style/numfmt-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const NumFmtXform = verquire('xlsx/xform/style/numfmt-xform'); diff --git a/spec/unit/xlsx/xform/style/styles-xform.spec.js b/spec/unit/xlsx/xform/style/styles-xform.spec.js index 5c5925a27..d8e97cc45 100644 --- a/spec/unit/xlsx/xform/style/styles-xform.spec.js +++ b/spec/unit/xlsx/xform/style/styles-xform.spec.js @@ -1,6 +1,6 @@ const fs = require('fs'); -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const StylesXform = verquire('xlsx/xform/style/styles-xform'); const XmlStream = verquire('utils/xml-stream'); diff --git a/spec/unit/xlsx/xform/style/underline-xform.spec.js b/spec/unit/xlsx/xform/style/underline-xform.spec.js index 944fc571b..30e8afa15 100644 --- a/spec/unit/xlsx/xform/style/underline-xform.spec.js +++ b/spec/unit/xlsx/xform/style/underline-xform.spec.js @@ -1,4 +1,4 @@ -const testXformHelper = require('./../test-xform-helper'); +const testXformHelper = require('../test-xform-helper'); const UnderlineXform = verquire('xlsx/xform/style/underline-xform'); diff --git a/spec/unit/xlsx/xform/table/auto-filter-xform.spec.js b/spec/unit/xlsx/xform/table/auto-filter-xform.spec.js index 502fd86d6..77de89999 100644 --- a/spec/unit/xlsx/xform/table/auto-filter-xform.spec.js +++ b/spec/unit/xlsx/xform/table/auto-filter-xform.spec.js @@ -1,42 +1,42 @@ -const testXformHelper = require('./../test-xform-helper'); - -const AutoFilterXform = verquire('xlsx/xform/table/auto-filter-xform'); - -const expectations = [ - { - title: 'showing filter', - create() { - return new AutoFilterXform(); - }, - initialModel: { - autoFilterRef: 'A1:B10', - columns: [ - {filterButton: false}, - {filterButton: true}, - {filterButton: true}, - ], - }, - preparedModel: { - autoFilterRef: 'A1:B10', - columns: [ - {colId: '0', filterButton: false}, - {colId: '1', filterButton: true}, - {colId: '2', filterButton: true}, - ], - }, - xml: - '' + - '' + - '' + - '' + - '', - get parsedModel() { - return this.initialModel; - }, - tests: ['prepare', 'render', 'renderIn', 'parse'], - }, -]; - -describe('AutoFilterXform', () => { - testXformHelper(expectations); -}); +const testXformHelper = require('../test-xform-helper'); + +const AutoFilterXform = verquire('xlsx/xform/table/auto-filter-xform'); + +const expectations = [ + { + title: 'showing filter', + create() { + return new AutoFilterXform(); + }, + initialModel: { + autoFilterRef: 'A1:B10', + columns: [ + {filterButton: false}, + {filterButton: true}, + {filterButton: true}, + ], + }, + preparedModel: { + autoFilterRef: 'A1:B10', + columns: [ + {colId: '0', filterButton: false}, + {colId: '1', filterButton: true}, + {colId: '2', filterButton: true}, + ], + }, + xml: + '' + + '' + + '' + + '' + + '', + get parsedModel() { + return this.initialModel; + }, + tests: ['prepare', 'render', 'renderIn', 'parse'], + }, +]; + +describe('AutoFilterXform', () => { + testXformHelper(expectations); +}); diff --git a/spec/unit/xlsx/xform/table/filter-column-xform.spec.js b/spec/unit/xlsx/xform/table/filter-column-xform.spec.js index 669cf084f..2d9900c17 100644 --- a/spec/unit/xlsx/xform/table/filter-column-xform.spec.js +++ b/spec/unit/xlsx/xform/table/filter-column-xform.spec.js @@ -1,38 +1,38 @@ -const testXformHelper = require('./../test-xform-helper'); - -const FilterColumnXform = verquire('xlsx/xform/table/filter-column-xform'); - -const expectations = [ - { - title: 'showing filter', - create() { - return new FilterColumnXform(); - }, - initialModel: {filterButton: true}, - preparedModel: {colId: '0', filterButton: true}, - xml: '', - get parsedModel() { - return this.initialModel; - }, - tests: ['prepare', 'render', 'renderIn', 'parse'], - options: {index: 0}, - }, - { - title: 'hidden filter', - create() { - return new FilterColumnXform(); - }, - initialModel: {filterButton: false}, - preparedModel: {colId: '1', filterButton: false}, - xml: '', - get parsedModel() { - return this.initialModel; - }, - tests: ['prepare', 'render', 'renderIn', 'parse'], - options: {index: 1}, - }, -]; - -describe('FilterColumnXform', () => { - testXformHelper(expectations); -}); +const testXformHelper = require('../test-xform-helper'); + +const FilterColumnXform = verquire('xlsx/xform/table/filter-column-xform'); + +const expectations = [ + { + title: 'showing filter', + create() { + return new FilterColumnXform(); + }, + initialModel: {filterButton: true}, + preparedModel: {colId: '0', filterButton: true}, + xml: '', + get parsedModel() { + return this.initialModel; + }, + tests: ['prepare', 'render', 'renderIn', 'parse'], + options: {index: 0}, + }, + { + title: 'hidden filter', + create() { + return new FilterColumnXform(); + }, + initialModel: {filterButton: false}, + preparedModel: {colId: '1', filterButton: false}, + xml: '', + get parsedModel() { + return this.initialModel; + }, + tests: ['prepare', 'render', 'renderIn', 'parse'], + options: {index: 1}, + }, +]; + +describe('FilterColumnXform', () => { + testXformHelper(expectations); +}); diff --git a/spec/unit/xlsx/xform/table/table-column-xform.spec.js b/spec/unit/xlsx/xform/table/table-column-xform.spec.js index b648299cc..109486e96 100644 --- a/spec/unit/xlsx/xform/table/table-column-xform.spec.js +++ b/spec/unit/xlsx/xform/table/table-column-xform.spec.js @@ -1,30 +1,30 @@ -const testXformHelper = require('./../test-xform-helper'); - -const TableColumnXform = verquire('xlsx/xform/table/table-column-xform'); - -const expectations = [ - { - title: 'label', - create() { - return new TableColumnXform(); - }, - preparedModel: {id: 1, name: 'Foo', totalsRowLabel: 'Bar'}, - xml: '', - parsedModel: {name: 'Foo', totalsRowLabel: 'Bar'}, - tests: ['render', 'renderIn', 'parse'], - }, - { - title: 'function', - create() { - return new TableColumnXform(); - }, - preparedModel: {id: 1, name: 'Foo', totalsRowFunction: 'Baz'}, - xml: '', - parsedModel: {name: 'Foo', totalsRowFunction: 'Baz'}, - tests: ['render', 'renderIn', 'parse'], - }, -]; - -describe('TableColumnXform', () => { - testXformHelper(expectations); -}); +const testXformHelper = require('../test-xform-helper'); + +const TableColumnXform = verquire('xlsx/xform/table/table-column-xform'); + +const expectations = [ + { + title: 'label', + create() { + return new TableColumnXform(); + }, + preparedModel: {id: 1, name: 'Foo', totalsRowLabel: 'Bar'}, + xml: '', + parsedModel: {name: 'Foo', totalsRowLabel: 'Bar'}, + tests: ['render', 'renderIn', 'parse'], + }, + { + title: 'function', + create() { + return new TableColumnXform(); + }, + preparedModel: {id: 1, name: 'Foo', totalsRowFunction: 'Baz'}, + xml: '', + parsedModel: {name: 'Foo', totalsRowFunction: 'Baz'}, + tests: ['render', 'renderIn', 'parse'], + }, +]; + +describe('TableColumnXform', () => { + testXformHelper(expectations); +}); diff --git a/spec/unit/xlsx/xform/table/table-style-info-xform.spec.js b/spec/unit/xlsx/xform/table/table-style-info-xform.spec.js index b0cc2aa74..5ce442bae 100644 --- a/spec/unit/xlsx/xform/table/table-style-info-xform.spec.js +++ b/spec/unit/xlsx/xform/table/table-style-info-xform.spec.js @@ -1,48 +1,48 @@ -const testXformHelper = require('./../test-xform-helper'); - -const TableStyleInfoXform = verquire('xlsx/xform/table/table-style-info-xform'); - -const expectations = [ - { - title: 'row', - create() { - return new TableStyleInfoXform(); - }, - preparedModel: { - theme: 'TableStyle', - showFirstColumn: false, - showLastColumn: false, - showRowStripes: true, - showColumnStripes: false, - }, - xml: - '', - get parsedModel() { - return this.preparedModel; - }, - tests: ['render', 'renderIn', 'parse'], - }, - { - title: 'col', - create() { - return new TableStyleInfoXform(); - }, - preparedModel: { - theme: null, - showFirstColumn: true, - showLastColumn: true, - showRowStripes: false, - showColumnStripes: true, - }, - xml: - '', - get parsedModel() { - return this.preparedModel; - }, - tests: ['render', 'renderIn', 'parse'], - }, -]; - -describe('TableStyleInfoXform', () => { - testXformHelper(expectations); -}); +const testXformHelper = require('../test-xform-helper'); + +const TableStyleInfoXform = verquire('xlsx/xform/table/table-style-info-xform'); + +const expectations = [ + { + title: 'row', + create() { + return new TableStyleInfoXform(); + }, + preparedModel: { + theme: 'TableStyle', + showFirstColumn: false, + showLastColumn: false, + showRowStripes: true, + showColumnStripes: false, + }, + xml: + '', + get parsedModel() { + return this.preparedModel; + }, + tests: ['render', 'renderIn', 'parse'], + }, + { + title: 'col', + create() { + return new TableStyleInfoXform(); + }, + preparedModel: { + theme: null, + showFirstColumn: true, + showLastColumn: true, + showRowStripes: false, + showColumnStripes: true, + }, + xml: + '', + get parsedModel() { + return this.preparedModel; + }, + tests: ['render', 'renderIn', 'parse'], + }, +]; + +describe('TableStyleInfoXform', () => { + testXformHelper(expectations); +}); diff --git a/spec/unit/xlsx/xform/table/table-xform.spec.js b/spec/unit/xlsx/xform/table/table-xform.spec.js index 71c6ef48e..098a9bb94 100644 --- a/spec/unit/xlsx/xform/table/table-xform.spec.js +++ b/spec/unit/xlsx/xform/table/table-xform.spec.js @@ -1,23 +1,23 @@ -const fs = require('fs'); - -const testXformHelper = require('./../test-xform-helper'); - -const TableXform = verquire('xlsx/xform/table/table-xform'); - -const expectations = [ - { - title: 'showing filter', - create() { - return new TableXform(); - }, - initialModel: null, - preparedModel: require('./data/table.1.1'), - xml: fs.readFileSync(`${__dirname}/data/table.1.2.xml`).toString(), - parsedModel: require('./data/table.1.3'), - tests: ['render', 'renderIn', 'parse'], - }, -]; - -describe('TableXform', () => { - testXformHelper(expectations); -}); +const fs = require('fs'); + +const testXformHelper = require('../test-xform-helper'); + +const TableXform = verquire('xlsx/xform/table/table-xform'); + +const expectations = [ + { + title: 'showing filter', + create() { + return new TableXform(); + }, + initialModel: null, + preparedModel: require('./data/table.1.1'), + xml: fs.readFileSync(`${__dirname}/data/table.1.2.xml`).toString(), + parsedModel: require('./data/table.1.3'), + tests: ['render', 'renderIn', 'parse'], + }, +]; + +describe('TableXform', () => { + testXformHelper(expectations); +}); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy