read-excel-file 5.2.27 → 5.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -3
- package/bundle/read-excel-file.min.js +1 -1
- package/bundle/read-excel-file.min.js.map +1 -1
- package/commonjs/package.json +1 -0
- package/commonjs/read/dropEmptyColumns.test.js.map +1 -1
- package/commonjs/read/dropEmptyRows.test.js.map +1 -1
- package/commonjs/read/getData.js +8 -5
- package/commonjs/read/getData.js.map +1 -1
- package/commonjs/read/parseCell.js +3 -3
- package/commonjs/read/parseCell.js.map +1 -1
- package/commonjs/read/parseCellValue.js +1 -1
- package/commonjs/read/parseCellValue.js.map +1 -1
- package/commonjs/read/parseCells.js +2 -2
- package/commonjs/read/parseCells.js.map +1 -1
- package/commonjs/read/parseDate.js +39 -8
- package/commonjs/read/parseDate.js.map +1 -1
- package/commonjs/read/parseDate.test.js.map +1 -1
- package/commonjs/read/parseDimensions.js +9 -4
- package/commonjs/read/parseDimensions.js.map +1 -1
- package/commonjs/read/parseFilePaths.js +1 -1
- package/commonjs/read/parseFilePaths.js.map +1 -1
- package/commonjs/read/parseProperties.js +1 -1
- package/commonjs/read/parseProperties.js.map +1 -1
- package/commonjs/read/parseSharedStrings.js +1 -1
- package/commonjs/read/parseSharedStrings.js.map +1 -1
- package/commonjs/read/parseSheet.js +3 -3
- package/commonjs/read/parseSheet.js.map +1 -1
- package/commonjs/read/parseStyles.js +1 -1
- package/commonjs/read/parseStyles.js.map +1 -1
- package/commonjs/read/readSheetNamesBrowser.js +1 -1
- package/commonjs/read/readSheetNamesBrowser.js.map +1 -1
- package/commonjs/read/readSheetNamesNode.js +1 -1
- package/commonjs/read/readSheetNamesNode.js.map +1 -1
- package/commonjs/read/readSheetNamesNode.test.js.map +1 -1
- package/commonjs/read/readSheetNamesWebWorker.js +1 -1
- package/commonjs/read/readSheetNamesWebWorker.js.map +1 -1
- package/commonjs/read/readXlsx.js +6 -6
- package/commonjs/read/readXlsx.js.map +1 -1
- package/commonjs/read/readXlsxFileBrowser.js +3 -3
- package/commonjs/read/readXlsxFileBrowser.js.map +1 -1
- package/commonjs/read/readXlsxFileContents.js +3 -3
- package/commonjs/read/readXlsxFileContents.js.map +1 -1
- package/commonjs/read/readXlsxFileNode.js +3 -3
- package/commonjs/read/readXlsxFileNode.js.map +1 -1
- package/commonjs/read/readXlsxFileNode.test.js.map +1 -1
- package/commonjs/read/readXlsxFileWebWorker.js +3 -3
- package/commonjs/read/readXlsxFileWebWorker.js.map +1 -1
- package/commonjs/read/schema/convertMapToSchema.test.js.map +1 -1
- package/commonjs/read/schema/convertToJson.js +4 -4
- package/commonjs/read/schema/convertToJson.js.map +1 -1
- package/commonjs/read/schema/convertToJson.test.js.map +1 -1
- package/commonjs/types/Email.test.js.map +1 -1
- package/commonjs/types/Integer.test.js.map +1 -1
- package/commonjs/types/URL.test.js.map +1 -1
- package/commonjs/xml/xlsx.js +1 -1
- package/commonjs/xml/xlsx.js.map +1 -1
- package/index.cjs +7 -0
- package/index.commonjs.js +11 -7
- package/index.js +6 -6
- package/modules/read/dropEmptyColumns.test.js.map +1 -1
- package/modules/read/dropEmptyRows.test.js.map +1 -1
- package/modules/read/getData.js +8 -5
- package/modules/read/getData.js.map +1 -1
- package/modules/read/parseCell.js +3 -3
- package/modules/read/parseCell.js.map +1 -1
- package/modules/read/parseCellValue.js +1 -1
- package/modules/read/parseCellValue.js.map +1 -1
- package/modules/read/parseCells.js +2 -2
- package/modules/read/parseCells.js.map +1 -1
- package/modules/read/parseDate.js +39 -8
- package/modules/read/parseDate.js.map +1 -1
- package/modules/read/parseDate.test.js.map +1 -1
- package/modules/read/parseDimensions.js +9 -4
- package/modules/read/parseDimensions.js.map +1 -1
- package/modules/read/parseFilePaths.js +1 -1
- package/modules/read/parseFilePaths.js.map +1 -1
- package/modules/read/parseProperties.js +1 -1
- package/modules/read/parseProperties.js.map +1 -1
- package/modules/read/parseSharedStrings.js +1 -1
- package/modules/read/parseSharedStrings.js.map +1 -1
- package/modules/read/parseSheet.js +3 -3
- package/modules/read/parseSheet.js.map +1 -1
- package/modules/read/parseStyles.js +1 -1
- package/modules/read/parseStyles.js.map +1 -1
- package/modules/read/readSheetNamesBrowser.js +1 -1
- package/modules/read/readSheetNamesBrowser.js.map +1 -1
- package/modules/read/readSheetNamesNode.js +1 -1
- package/modules/read/readSheetNamesNode.js.map +1 -1
- package/modules/read/readSheetNamesNode.test.js.map +1 -1
- package/modules/read/readSheetNamesWebWorker.js +1 -1
- package/modules/read/readSheetNamesWebWorker.js.map +1 -1
- package/modules/read/readXlsx.js +6 -6
- package/modules/read/readXlsx.js.map +1 -1
- package/modules/read/readXlsxFileBrowser.js +3 -3
- package/modules/read/readXlsxFileBrowser.js.map +1 -1
- package/modules/read/readXlsxFileContents.js +3 -3
- package/modules/read/readXlsxFileContents.js.map +1 -1
- package/modules/read/readXlsxFileNode.js +3 -3
- package/modules/read/readXlsxFileNode.js.map +1 -1
- package/modules/read/readXlsxFileNode.test.js.map +1 -1
- package/modules/read/readXlsxFileWebWorker.js +3 -3
- package/modules/read/readXlsxFileWebWorker.js.map +1 -1
- package/modules/read/schema/convertMapToSchema.test.js.map +1 -1
- package/modules/read/schema/convertToJson.js +4 -4
- package/modules/read/schema/convertToJson.js.map +1 -1
- package/modules/read/schema/convertToJson.test.js.map +1 -1
- package/modules/types/Email.test.js.map +1 -1
- package/modules/types/Integer.test.js.map +1 -1
- package/modules/types/URL.test.js.map +1 -1
- package/modules/xml/xlsx.js +1 -1
- package/modules/xml/xlsx.js.map +1 -1
- package/node/index.cjs +7 -0
- package/node/index.commonjs.js +12 -7
- package/node/index.js +6 -6
- package/node/package.json +8 -0
- package/package.json +44 -19
- package/runnable/create-commonjs-package-json.js +11 -0
- package/schema/index.cjs +2 -0
- package/schema/index.commonjs.js +6 -2
- package/schema/index.js +1 -1
- package/schema/package.json +8 -0
- package/web-worker/index.cjs +7 -0
- package/web-worker/index.commonjs.js +11 -7
- package/web-worker/index.js +6 -6
- package/web-worker/package.json +8 -0
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { default as default } from './modules/read/readXlsxFileBrowser'
|
|
2
|
-
export { default as readSheetNames } from './modules/read/readSheetNamesBrowser'
|
|
3
|
-
export { default as parseExcelDate } from './modules/read/parseDate'
|
|
4
|
-
export { default as Integer } from './modules/types/Integer'
|
|
5
|
-
export { default as Email } from './modules/types/Email'
|
|
6
|
-
export { default as URL } from './modules/types/URL'
|
|
1
|
+
export { default as default } from './modules/read/readXlsxFileBrowser.js'
|
|
2
|
+
export { default as readSheetNames } from './modules/read/readSheetNamesBrowser.js'
|
|
3
|
+
export { default as parseExcelDate } from './modules/read/parseDate.js'
|
|
4
|
+
export { default as Integer } from './modules/types/Integer.js'
|
|
5
|
+
export { default as Email } from './modules/types/Email.js'
|
|
6
|
+
export { default as URL } from './modules/types/URL.js'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../source/read/dropEmptyColumns.test.js"],"names":["dropEmptyColumns","describe","it","onlyTrimAtTheEnd","should","deep","equal"],"mappings":"AAAA,OAAOA,gBAAP,MAA6B,
|
|
1
|
+
{"version":3,"sources":["../../source/read/dropEmptyColumns.test.js"],"names":["dropEmptyColumns","describe","it","onlyTrimAtTheEnd","should","deep","equal"],"mappings":"AAAA,OAAOA,gBAAP,MAA6B,uBAA7B;AAEAC,QAAQ,CAAC,kBAAD,EAAqB,YAAM;AAClCC,EAAAA,EAAE,CAAC,6CAAD,EAAgD,YAAM;AACvDF,IAAAA,gBAAgB,CAAC,CAChB,CAAC,IAAD,EAAO,GAAP,EAAY,GAAZ,EAAiB,GAAjB,EAAsB,IAAtB,EAA4B,IAA5B,CADgB,EAEhB,CAAC,IAAD,EAAO,GAAP,EAAY,IAAZ,EAAkB,IAAlB,EAAwB,IAAxB,EAA8B,IAA9B,CAFgB,EAGhB,CAAC,IAAD,EAAO,IAAP,EAAa,IAAb,EAAmB,I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D,EAAO,IAAP,EAAa,IAAb,EAAmB,IAAnB,CAHkB,EAIlB,CAAC,IAAD,EAAO,GAAP,EAAY,GAAZ,EAAiB,GAAjB,CAJkB,CANnB;AAYA,GAbC,CAAF;AAcA,CAhCO,CAAR","sourcesContent":["import dropEmptyColumns from './dropEmptyColumns.js'\r\n\r\ndescribe('dropEmptyColumns', () => {\r\n\tit('should drop empty columns (only at the end)', () => {\r\n\t\tdropEmptyColumns([\r\n\t\t\t[null, 'A', 'B', 'C', null, null],\r\n\t\t\t[null, 'D', null, null, null, null],\r\n\t\t\t[null, null, null, null, null, null],\r\n\t\t\t[null, null, 'E', 'F', 'G', null]\r\n\t\t], {\r\n\t\t\tonlyTrimAtTheEnd: true\r\n\t\t})\r\n\t\t.should.deep.equal([\r\n\t\t\t[null, 'A', 'B', 'C', null],\r\n\t\t\t[null, 'D', null, null, null],\r\n\t\t\t[null, null, null, null, null],\r\n\t\t\t[null, null, 'E', 'F', 'G']\r\n\t\t])\r\n\t})\r\n\r\n\tit('should drop empty columns', () => {\r\n\t\tdropEmptyColumns([\r\n\t\t\t[null, 'A', 'B', 'C', null, null],\r\n\t\t\t[null, 'D', null, null, null, null],\r\n\t\t\t[null, null, null, null, null, null],\r\n\t\t\t[null, null, 'E', 'F', 'G', null]\r\n\t\t])\r\n\t\t.should.deep.equal([\r\n\t\t\t['A', 'B', 'C', null],\r\n\t\t\t['D', null, null, null],\r\n\t\t\t[null, null, null, null],\r\n\t\t\t[null, 'E', 'F', 'G']\r\n\t\t])\r\n\t})\r\n})"],"file":"dropEmptyColumns.test.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../source/read/dropEmptyRows.test.js"],"names":["dropEmptyRows","describe","it","onlyTrimAtTheEnd","should","deep","equal","rowMap"],"mappings":"AAAA,OAAOA,aAAP,MAA0B,
|
|
1
|
+
{"version":3,"sources":["../../source/read/dropEmptyRows.test.js"],"names":["dropEmptyRows","describe","it","onlyTrimAtTheEnd","should","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R,CAQaC,KARb,CAQmB,CAClB,CAAC,GAAD,EAAM,GAAN,EAAW,GAAX,CADkB,EAElB,CAAC,IAAD,EAAO,GAAP,EAAY,IAAZ,CAFkB,EAGlB,CAAC,GAAD,EAAM,GAAN,EAAW,GAAX,CAHkB,CARnB;AAaA,GAdC,CAAF;AAgBAJ,EAAAA,EAAE,CAAC,kDAAD,EAAqD,YAAM;AAC5D,QAAMK,MAAM,GAAG,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAU,CAAV,EAAa,CAAb,CAAf;AAEAP,IAAAA,aAAa,CAAC,CACb,CAAC,IAAD,EAAO,IAAP,EAAa,IAAb,CADa,EAEb,CAAC,GAAD,EAAM,GAAN,EAAW,GAAX,CAFa,EAGb,CAAC,IAAD,EAAO,GAAP,EAAY,IAAZ,CAHa,EAIb,CAAC,IAAD,EAAO,IAAP,EAAa,IAAb,CAJa,EAKb,CAAC,GAAD,EAAM,GAAN,EAAW,GAAX,CALa,CAAD,EAOb;AAAEO,MAAAA,MAAM,EAANA;AAAF,KAPa,CAAb,CAQCH,MARD,CAQQC,IARR,CAQaC,KARb,CAQmB,CAClB,CAAC,GAAD,EAAM,GAAN,EAAW,GAAX,CADkB,EAElB,CAAC,IAAD,EAAO,GAAP,EAAY,IAAZ,CAFkB,EAGlB,CAAC,GAAD,EAAM,GAAN,EAAW,GAAX,CAHkB,CARnB;AAcAC,IAAAA,MAAM,CAACH,MAAP,CAAcC,IAAd,CAAmBC,KAAnB,CAAyB,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CAAzB;AACA,GAlBC,CAAF;AAmBA,CAxDO,CAAR","sourcesContent":["import dropEmptyRows from './dropEmptyRows.js'\r\n\r\ndescribe('dropEmptyRows', () => {\r\n\tit('should drop empty rows (only at the end)', () => {\r\n\t\tdropEmptyRows([\r\n\t\t\t[null, null, null],\r\n\t\t\t['A', 'B', 'C'],\r\n\t\t\t[null, 'D', null],\r\n\t\t\t[null, null, null],\r\n\t\t\t['E', 'F', 'G'],\r\n\t\t\t[null, null, null]\r\n\t\t], {\r\n\t\t\tonlyTrimAtTheEnd: true\r\n\t\t})\r\n\t\t.should.deep.equal([\r\n\t\t\t[null, null, null],\r\n\t\t\t['A', 'B', 'C'],\r\n\t\t\t[null, 'D', null],\r\n\t\t\t[null, null, null],\r\n\t\t\t['E', 'F', 'G']\r\n\t\t])\r\n\t})\r\n\r\n\tit('should drop empty rows', () => {\r\n\t\tdropEmptyRows([\r\n\t\t\t[null, null, null],\r\n\t\t\t['A', 'B', 'C'],\r\n\t\t\t[null, 'D', null],\r\n\t\t\t[null, null, null],\r\n\t\t\t['E', 'F', 'G'],\r\n\t\t\t[null, null, null]\r\n\t\t])\r\n\t\t.should.deep.equal([\r\n\t\t\t['A', 'B', 'C'],\r\n\t\t\t[null, 'D', null],\r\n\t\t\t['E', 'F', 'G']\r\n\t\t])\r\n\t})\r\n\r\n\tit('should generate row map when dropping empty rows', () => {\r\n\t\tconst rowMap = [0, 1, 2, 3, 4]\r\n\r\n\t\tdropEmptyRows([\r\n\t\t\t[null, null, null],\r\n\t\t\t['A', 'B', 'C'],\r\n\t\t\t[null, 'D', null],\r\n\t\t\t[null, null, null],\r\n\t\t\t['E', 'F', 'G']\r\n\t\t],\r\n\t\t{ rowMap })\r\n\t\t.should.deep.equal([\r\n\t\t\t['A', 'B', 'C'],\r\n\t\t\t[null, 'D', null],\r\n\t\t\t['E', 'F', 'G']\r\n\t\t])\r\n\r\n\t\trowMap.should.deep.equal([1, 2, 4])\r\n\t})\r\n})"],"file":"dropEmptyRows.test.js"}
|
package/modules/read/getData.js
CHANGED
|
@@ -12,8 +12,8 @@ function _iterableToArrayLimit(arr, i) { var _i = arr && (typeof Symbol !== "und
|
|
|
12
12
|
|
|
13
13
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
14
14
|
|
|
15
|
-
import dropEmptyRows from './dropEmptyRows';
|
|
16
|
-
import dropEmptyColumns from './dropEmptyColumns';
|
|
15
|
+
import dropEmptyRows from './dropEmptyRows.js';
|
|
16
|
+
import dropEmptyColumns from './dropEmptyColumns.js';
|
|
17
17
|
export default function getData(sheet, options) {
|
|
18
18
|
var dimensions = sheet.dimensions,
|
|
19
19
|
cells = sheet.cells; // If the sheet is empty.
|
|
@@ -46,7 +46,7 @@ export default function getData(sheet, options) {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
i++;
|
|
49
|
-
} // Fill in spreadsheet data
|
|
49
|
+
} // Fill in spreadsheet `data`.
|
|
50
50
|
// (this code implies that `cells` aren't necessarily sorted by row and column:
|
|
51
51
|
// maybe that's not correct, this piece code was initially copy-pasted
|
|
52
52
|
// from some other library that used `XPath`)
|
|
@@ -59,8 +59,11 @@ export default function getData(sheet, options) {
|
|
|
59
59
|
// const rowIndex = cell.row - leftTop.row
|
|
60
60
|
// const columnIndex = cell.column - leftTop.column
|
|
61
61
|
var rowIndex = cell.row - 1;
|
|
62
|
-
var columnIndex = cell.column - 1;
|
|
63
|
-
|
|
62
|
+
var columnIndex = cell.column - 1; // Ignore the data in the cell if it's outside of the spreadsheet's "dimensions".
|
|
63
|
+
|
|
64
|
+
if (columnIndex < colsCount && rowIndex < rowsCount) {
|
|
65
|
+
data[rowIndex][columnIndex] = cell.value;
|
|
66
|
+
}
|
|
64
67
|
} // Fill in the row map.
|
|
65
68
|
|
|
66
69
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../source/read/getData.js"],"names":["dropEmptyRows","dropEmptyColumns","getData","sheet","options","dimensions","cells","length","leftTop","rightBottom","colsCount","column","rowsCount","row","data","Array","i","j","cell","rowIndex","columnIndex","value","rowMap","onlyTrimAtTheEnd","transformData"],"mappings":";;;;;;;;;;;;;;AAAA,OAAOA,aAAP,MAA0B,
|
|
1
|
+
{"version":3,"sources":["../../source/read/getData.js"],"names":["dropEmptyRows","dropEmptyColumns","getData","sheet","options","dimensions","cells","length","leftTop","rightBottom","colsCount","column","rowsCount","row","data","Array","i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IS,WAAW,GAAGV,SAAd,IAA2BS,QAAQ,GAAGP,SAA1C,EAAqD;AACnDE,MAAAA,IAAI,CAACK,QAAD,CAAJ,CAAeC,WAAf,IAA8BF,IAAI,CAACG,KAAnC;AACD;AACF,GA9C6C,CAgD9C;;;AACA,MAAQC,MAAR,GAAmBlB,OAAnB,CAAQkB,MAAR;;AACA,MAAIA,MAAJ,EAAY;AACV,QAAIN,GAAC,GAAG,CAAR;;AACA,WAAOA,GAAC,GAAGF,IAAI,CAACP,MAAhB,EAAwB;AACtBe,MAAAA,MAAM,CAACN,GAAD,CAAN,GAAYA,GAAZ;AACAA,MAAAA,GAAC;AACF;AACF,GAxD6C,CA0D9C;;;AACAF,EAAAA,IAAI,GAAGd,aAAa,CAClBC,gBAAgB,CAACa,IAAD,EAAO;AAAES,IAAAA,gBAAgB,EAAE;AAApB,GAAP,CADE,EAElB;AAAEA,IAAAA,gBAAgB,EAAE,IAApB;AAA0BD,IAAAA,MAAM,EAANA;AAA1B,GAFkB,CAApB,CA3D8C,CAgE9C;;AACA,MAAIlB,OAAO,CAACoB,aAAZ,EAA2B;AACzBV,IAAAA,IAAI,GAAGV,OAAO,CAACoB,aAAR,CAAsBV,IAAtB,CAAP,CADyB,CAEzB;AACA;AACA;AACA;AACA;AACD;;AAED,SAAOA,IAAP;AACD","sourcesContent":["import dropEmptyRows from './dropEmptyRows.js'\r\nimport dropEmptyColumns from './dropEmptyColumns.js'\r\n\r\nexport default function getData(sheet, options) {\r\n const { dimensions, cells } = sheet\r\n\r\n // If the sheet is empty.\r\n if (cells.length === 0) {\r\n return []\r\n }\r\n\r\n const [leftTop, rightBottom] = dimensions\r\n\r\n // Don't discard empty rows or columns at the start.\r\n // https://github.com/catamphetamine/read-excel-file/issues/102\r\n // const colsCount = (rightBottom.column - leftTop.column) + 1\r\n // const rowsCount = (rightBottom.row - leftTop.row) + 1\r\n\r\n const colsCount = rightBottom.column\r\n const rowsCount = rightBottom.row\r\n\r\n // Initialize spreadsheet data structure.\r\n let data = new Array(rowsCount)\r\n let i = 0\r\n while (i < rowsCount) {\r\n data[i] = new Array(colsCount)\r\n let j = 0\r\n while (j < colsCount) {\r\n data[i][j] = null\r\n j++\r\n }\r\n i++\r\n }\r\n\r\n // Fill in spreadsheet `data`.\r\n // (this code implies that `cells` aren't necessarily sorted by row and column:\r\n // maybe that's not correct, this piece code was initially copy-pasted\r\n // from some other library that used `XPath`)\r\n for (const cell of cells) {\r\n // Don't discard empty rows or columns at the start.\r\n // https://github.com/catamphetamine/read-excel-file/issues/102\r\n // const rowIndex = cell.row - leftTop.row\r\n // const columnIndex = cell.column - leftTop.column\r\n const rowIndex = cell.row - 1\r\n const columnIndex = cell.column - 1\r\n // Ignore the data in the cell if it's outside of the spreadsheet's \"dimensions\".\r\n if (columnIndex < colsCount && rowIndex < rowsCount) {\r\n data[rowIndex][columnIndex] = cell.value\r\n }\r\n }\r\n\r\n // Fill in the row map.\r\n const { rowMap } = options\r\n if (rowMap) {\r\n let i = 0\r\n while (i < data.length) {\r\n rowMap[i] = i\r\n i++\r\n }\r\n }\r\n\r\n // Drop empty columns or rows.\r\n data = dropEmptyRows(\r\n dropEmptyColumns(data, { onlyTrimAtTheEnd: true }),\r\n { onlyTrimAtTheEnd: true, rowMap }\r\n )\r\n\r\n // Optionally transform data before applying `schema`.\r\n if (options.transformData) {\r\n data = options.transformData(data)\r\n // data = options.transformData(data, {\r\n // dropEmptyRowsAndColumns(data) {\r\n // return dropEmptyRows(dropEmptyColumns(data), { rowMap })\r\n // }\r\n // })\r\n }\r\n\r\n return data\r\n}"],"file":"getData.js"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import parseCellValue from './parseCellValue';
|
|
2
|
-
import { parseCellCoordinates } from './coordinates';
|
|
3
|
-
import { getCellValue, getCellInlineStringValue } from '../xml/xlsx'; // Example of a `<c/>`ell element:
|
|
1
|
+
import parseCellValue from './parseCellValue.js';
|
|
2
|
+
import { parseCellCoordinates } from './coordinates.js';
|
|
3
|
+
import { getCellValue, getCellInlineStringValue } from '../xml/xlsx.js'; // Example of a `<c/>`ell element:
|
|
4
4
|
//
|
|
5
5
|
// <c>
|
|
6
6
|
// <f>string</f> — formula.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../source/read/parseCell.js"],"names":["parseCellValue","parseCellCoordinates","getCellValue","getCellInlineStringValue","parseCell","node","sheet","xml","values","styles","properties","options","coords","getAttribute","valueElement","value","textContent","type","hasAttribute","row","column","getInlineStringValue","getStyleId"],"mappings":"AAAA,OAAOA,cAAP,MAA2B,
|
|
1
|
+
{"version":3,"sources":["../../source/read/parseCell.js"],"names":["parseCellValue","parseCellCoordinates","getCellValue","getCellInlineStringValue","parseCell","node","sheet","xml","values","styles","properties","options","coords","getAttribute","valueElement","value","textContent","type","hasAttribute","row","column","getInlineStringValue","getStyleId"],"mappings":"AAAA,OAAOA,cAAP,MAA2B,qBAA3B;AAEA,SACEC,oBADF,QAEO,kBAFP;AAIA,SACEC,YADF,EAEEC,wBAFF,QAGO,gBAHP,C,CAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,SAAT,CAAmBC,IAAnB,EAAyBC,KAAzB,EAAgCC,GAAhC,EAAqCC,MAArC,EAA6CC,MAA7C,EAAqDC,UAArD,EAAiEC,OAAjE,EAA0E;AACvF,MAAMC,MAAM,GAAGX,oBAAoB,CAACI,IAAI,CAACQ,YAAL,CAAkB,GAAlB,CAAD,CAAnC;AAEA,MAAMC,YAAY,GAAGZ,YAAY,CAACI,KAAD,EAAQD,IAAR,CAAjC,CAHuF,CAKvF;AACA;AACA;;AACA,MAAIU,KAAK,GAAGD,YAAY,IAAIA,YAAY,CAACE,WAAzC;AAEA,MAAIC,IAAJ;;AACA,MAAIZ,IAAI,CAACa,YAAL,CAAkB,GAAlB,CAAJ,EAA4B;AAC1BD,IAAAA,IAAI,GAAGZ,IAAI,CAACQ,YAAL,CAAkB,GAAlB,CAAP;AACD;;AAED,SAAO;AACLM,IAAAA,GAAG,EAAEP,MAAM,CAAC,CAAD,CADN;AAELQ,IAAAA,MAAM,EAAER,MAAM,CAAC,CAAD,CAFT;AAGLG,IAAAA,KAAK,EAAEf,cAAc,CAACe,KAAD,EAAQE,IAAR,EAAc;AACjCI,MAAAA,oBAAoB,EAAE;AAAA,eAAMlB,wBAAwB,CAACG,KAAD,EAAQD,IAAR,CAA9B;AAAA,OADW;AAEjCiB,MAAAA,UAAU,EAAE;AAAA,eAAMjB,IAAI,CAACQ,YAAL,CAAkB,GAAlB,CAAN;AAAA,OAFqB;AAGjCJ,MAAAA,MAAM,EAANA,MAHiC;AAIjCD,MAAAA,MAAM,EAANA,MAJiC;AAKjCE,MAAAA,UAAU,EAAVA,UALiC;AAMjCC,MAAAA,OAAO,EAAPA;AANiC,KAAd;AAHhB,GAAP;AAYD","sourcesContent":["import parseCellValue from './parseCellValue.js'\r\n\r\nimport {\r\n parseCellCoordinates\r\n} from './coordinates.js'\r\n\r\nimport {\r\n getCellValue,\r\n getCellInlineStringValue\r\n} from '../xml/xlsx.js'\r\n\r\n// Example of a `<c/>`ell element:\r\n//\r\n// <c>\r\n// <f>string</f> — formula.\r\n// <v>string</v> — formula pre-computed value.\r\n// <is>\r\n// <t>string</t> — an `inlineStr` string (rather than a \"common string\" from a dictionary).\r\n// <r>\r\n// <rPr>\r\n// ...\r\n// </rPr>\r\n// <t>string</t>\r\n// </r>\r\n// <rPh sb=\"1\" eb=\"1\">\r\n// <t>string</t>\r\n// </rPh>\r\n// <phoneticPr fontId=\"1\"/>\r\n// </is>\r\n// <extLst>\r\n// <ext>\r\n// <!--any element-->\r\n// </ext>\r\n// </extLst>\r\n// </c>\r\n//\r\nexport default function parseCell(node, sheet, xml, values, styles, properties, options) {\r\n const coords = parseCellCoordinates(node.getAttribute('r'))\r\n\r\n const valueElement = getCellValue(sheet, node)\r\n\r\n // For `xpath`, `value` can be `undefined` while for native `DOMParser` it's `null`.\r\n // So using `value && ...` instead of `if (value !== undefined) { ... }` here\r\n // for uniform compatibility with both `xpath` and native `DOMParser`.\r\n let value = valueElement && valueElement.textContent\r\n\r\n let type\r\n if (node.hasAttribute('t')) {\r\n type = node.getAttribute('t')\r\n }\r\n\r\n return {\r\n row: coords[0],\r\n column: coords[1],\r\n value: parseCellValue(value, type, {\r\n getInlineStringValue: () => getCellInlineStringValue(sheet, node),\r\n getStyleId: () => node.getAttribute('s'),\r\n styles,\r\n values,\r\n properties,\r\n options\r\n })\r\n }\r\n}"],"file":"parseCell.js"}
|
|
@@ -4,7 +4,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
4
4
|
|
|
5
5
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
6
6
|
|
|
7
|
-
import parseDate from './parseDate'; // https://hexdocs.pm/xlsxir/number_styles.html
|
|
7
|
+
import parseDate from './parseDate.js'; // https://hexdocs.pm/xlsxir/number_styles.html
|
|
8
8
|
|
|
9
9
|
var BUILT_IN_DATE_NUMBER_FORMAT_IDS = [14, 15, 16, 17, 18, 19, 20, 21, 22, 27, 30, 36, 45, 46, 47, 50, 57];
|
|
10
10
|
export default function getCellValue(value, type, _ref) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../source/read/parseCellValue.js"],"names":["parseDate","BUILT_IN_DATE_NUMBER_FORMAT_IDS","getCellValue","value","type","getInlineStringValue","getStyleId","styles","values","properties","options","trim","undefined","Error","parseInt","decodeError","Date","parseFloat","styleId","style","indexOf","numberFormat","id","dateFormat","template","smartDateParser","isDateTemplate","TypeError","errorCode","toLowerCase","tokens","split","token","DATE_TEMPLATE_TOKENS"],"mappings":";;;;;;AAAA,OAAOA,SAAP,MAAsB,aAAtB,C,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Ae3B;AACA,IAhB2B,EAiB3B;AACA,GAlB2B,EAmB3B;AACA,IApB2B,EAqB3B;AACA,KAtB2B,EAuB3B;AACA,MAxB2B,EAyB3B;AACA,IA1B2B,EA2B3B;AACA,MA5B2B,CAA7B","sourcesContent":["import parseDate from './parseDate'\r\n\r\n// https://hexdocs.pm/xlsxir/number_styles.html\r\nconst BUILT_IN_DATE_NUMBER_FORMAT_IDS = [14,15,16,17,18,19,20,21,22,27,30,36,45,46,47,50,57]\r\n\r\nexport default function getCellValue(value, type, {\r\n\tgetInlineStringValue,\r\n\tgetStyleId,\r\n\tstyles,\r\n\tvalues,\r\n\tproperties,\r\n\toptions\r\n}) {\r\n if (!type) {\r\n // Default cell type is \"n\" (numeric).\r\n // http://www.datypic.com/sc/ooxml/t-ssml_CT_Cell.html\r\n type = 'n'\r\n }\r\n\r\n // Available Excel cell types:\r\n // https://github.com/SheetJS/sheetjs/blob/19620da30be2a7d7b9801938a0b9b1fd3c4c4b00/docbits/52_datatype.md\r\n //\r\n // Some other document (seems to be old):\r\n // http://webapp.docx4java.org/OnlineDemo/ecma376/SpreadsheetML/ST_CellType.html\r\n //\r\n switch (type) {\r\n // If the cell contains formula string.\r\n case 'str':\r\n value = value.trim()\r\n if (value === '') {\r\n value = undefined\r\n }\r\n break\r\n\r\n // If the cell contains an \"inline\" (not \"shared\") string.\r\n case 'inlineStr':\r\n value = getInlineStringValue()\r\n if (value === undefined) {\r\n throw new Error(`Unsupported \"inline string\" cell value structure`) // : ${cellNode.textContent}`)\r\n }\r\n value = value.trim()\r\n if (value === '') {\r\n value = undefined\r\n }\r\n break\r\n\r\n // If the cell contains a \"shared\" string.\r\n // \"Shared\" strings is a way for an Excel editor to reduce\r\n // the file size by storing \"commonly used\" strings in a dictionary\r\n // and then referring to such strings by their index in that dictionary.\r\n case 's':\r\n // If a cell has no value then there's no `<c/>` element for it.\r\n // If a `<c/>` element exists then it's not empty.\r\n // The `<v/>`alue is a key in the \"shared strings\" dictionary of the\r\n // XLSX file, so look it up in the `values` dictionary by the numeric key.\r\n value = values[parseInt(value)]\r\n value = value.trim()\r\n if (value === '') {\r\n value = undefined\r\n }\r\n break\r\n\r\n case 'b':\r\n value = value === '1' ? true : false\r\n break\r\n\r\n // Stub: blank stub cell that is ignored by data processing utilities.\r\n case 'z':\r\n value = undefined\r\n break\r\n\r\n // Error: `value` is a numeric code.\r\n // They also wrote: \"and `w` property stores its common name\".\r\n // It's unclear what they meant by that.\r\n case 'e':\r\n value = decodeError(value)\r\n break\r\n\r\n // Date: a string to be parsed as a date.\r\n // (usually a string in \"ISO 8601\" format)\r\n case 'd':\r\n if (value === undefined) {\r\n break\r\n }\r\n value = new Date(value)\r\n break\r\n\r\n case 'n':\r\n if (value === undefined) {\r\n break\r\n }\r\n value = parseFloat(value)\r\n // XLSX does have \"d\" type for dates, but it's not commonly used.\r\n // Instead, spreadsheets prefer using \"n\" type for dates for some reason.\r\n //\r\n // In such cases, sometimes a \"date\" type could be heuristically detected\r\n // by looking at such numeric value \"format\" and seeing if it's a date-specific one.\r\n // https://github.com/catamphetamine/read-excel-file/issues/3#issuecomment-395770777\r\n //\r\n // The list of generic numeric value \"formats\":\r\n // https://xlsxwriter.readthedocs.io/format.html#format-set-num-format\r\n //\r\n const styleId = getStyleId()\r\n if (styleId) {\r\n // styleId = parseInt(styleId)\r\n const style = styles[styleId]\r\n if (!style) {\r\n throw new Error(`Cell style not found: ${styleId}`)\r\n }\r\n if (BUILT_IN_DATE_NUMBER_FORMAT_IDS.indexOf(parseInt(style.numberFormat.id)) >= 0 ||\r\n (options.dateFormat && style.numberFormat.template === options.dateFormat) ||\r\n (options.smartDateParser !== false && style.numberFormat.template && isDateTemplate(style.numberFormat.template))) {\r\n value = parseDate(value, properties)\r\n }\r\n }\r\n break\r\n\r\n default:\r\n throw new TypeError(`Cell type not supported: ${type}`)\r\n }\r\n\r\n // Convert empty values to `null`.\r\n if (value === undefined) {\r\n value = null\r\n }\r\n\r\n return value\r\n}\r\n\r\n// Decodes numeric error code to a string code.\r\n// https://github.com/SheetJS/sheetjs/blob/19620da30be2a7d7b9801938a0b9b1fd3c4c4b00/docbits/52_datatype.md\r\nfunction decodeError(errorCode) {\r\n // While the error values are determined by the application,\r\n // the following are some example error values that could be used:\r\n switch (errorCode) {\r\n case 0x00:\r\n return '#NULL!'\r\n case 0x07:\r\n return '#DIV/0!'\r\n case 0x0F:\r\n return '#VALUE!'\r\n case 0x17:\r\n return '#REF!'\r\n case 0x1D:\r\n return '#NAME?'\r\n case 0x24:\r\n return '#NUM!'\r\n case 0x2A:\r\n return '#N/A'\r\n case 0x2B:\r\n return '#GETTING_DATA'\r\n default:\r\n // Such error code doesn't exist. I made it up.\r\n return `#ERROR_${errorCode}`\r\n }\r\n}\r\n\r\nfunction isDateTemplate(template) {\r\n // Date format tokens could be in upper case or in lower case.\r\n // There seems to be no single standard.\r\n // So lowercase the template first.\r\n template = template.toLowerCase()\r\n const tokens = template.split(/\\W+/)\r\n for (const token of tokens) {\r\n if (DATE_TEMPLATE_TOKENS.indexOf(token) < 0) {\r\n return false\r\n }\r\n }\r\n return true\r\n}\r\n\r\n// These tokens could be in upper case or in lower case.\r\n// There seems to be no single standard, so using lower case.\r\nconst DATE_TEMPLATE_TOKENS = [\r\n // Seconds (min two digits). Example: \"05\".\r\n 'ss',\r\n // Minutes (min two digits). Example: \"05\". Could also be \"Months\". Weird.\r\n 'mm',\r\n // Hours. Example: \"1\".\r\n 'h',\r\n // Hours (min two digits). Example: \"01\".\r\n 'hh',\r\n // \"AM\" part of \"AM/PM\". Lowercased just in case.\r\n 'am',\r\n // \"PM\" part of \"AM/PM\". Lowercased just in case.\r\n 'pm',\r\n // Day. Example: \"1\"\r\n 'd',\r\n // Day (min two digits). Example: \"01\"\r\n 'dd',\r\n // Month (numeric). Example: \"1\".\r\n 'm',\r\n // Month (numeric, min two digits). Example: \"01\". Could also be \"Minutes\". Weird.\r\n 'mm',\r\n // Month (shortened month name). Example: \"Jan\".\r\n 'mmm',\r\n // Month (full month name). Example: \"January\".\r\n 'mmmm',\r\n // Two-digit year. Example: \"20\".\r\n 'yy',\r\n // Full year. Example: \"2020\".\r\n 'yyyy'\r\n];"],"file":"parseCellValue.js"}
|
|
1
|
+
{"version":3,"sources":["../../source/read/parseCellValue.js"],"names":["parseDate","BUILT_IN_DATE_NUMBER_FORMAT_IDS","getCellValue","value","type","getInlineStringValue","getStyleId","styles","values","properties","options","trim","undefined","Error","parseInt","decodeError","Date","parseFloat","styleId","style","indexOf","numberFormat","id","dateFormat","template","smartDateParser","isDateTemplate","TypeError","errorCode","toLowerCase","tokens","split","token","DATE_TEMPLATE_TOKENS"],"mappings":";;;;;;AAAA,OAAOA,SAAP,MAAsB,gBAAtB,C,CAEA;;AACA,IAAMC,+BAA+B,GAAG,CAAC,EAAD,EAAI,EAAJ,EAAO,EAAP,EAAU,EAAV,EAAa,EAAb,EAAgB,EAAhB,EAAmB,EAAnB,EAAsB,EAAtB,EAAyB,EAAzB,EAA4B,EAA5B,EAA+B,EAA/B,EAAkC,EAAlC,EAAqC,EAArC,EAAwC,EAAxC,EAA2C,EAA3C,EAA8C,EAA9C,EAAiD,EAAjD,CAAxC;AAEA,eAAe,SAASC,YAAT,CAAsBC,KAAtB,EAA6BC,IAA7B,QAOZ;AAAA,MANFC,oBAME,QANFA,oBAME;AAAA,MALFC,UAKE,QALFA,UAKE;AAAA,MAJFC,MAIE,QAJFA,MAIE;AAAA,MAHFC,MAGE,QAHFA,MAGE;AAAA,MAFFC,UAEE,QAFFA,UAEE;AAAA,MADFC,OACE,QADFA,OACE;;AACD,MAAI,CAACN,IAAL,EAAW;AACT;AACA;AACAA,IAAAA,IAAI,GAAG,GAAP;AACD,GALA,CAOD;AACA;AACA;AACA;AACA;AACA;;;AACA,UAAQA,IAAR;AACE;AACA,SAAK,KAAL;AACED,MAAAA,KAAK,GAAGA,KAAK,CAACQ,IAAN,EAAR;;AACA,UAAIR,KAAK,KAAK,EAAd,EAAkB;AAChBA,QAAAA,K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,GAAGA,QAAQ,CAACK,WAAT,EAAX;AACA,MAAMC,MAAM,GAAGN,QAAQ,CAACO,KAAT,CAAe,KAAf,CAAf;;AACA,uDAAoBD,MAApB,wCAA4B;AAAA,QAAjBE,KAAiB;;AAC1B,QAAIC,oBAAoB,CAACb,OAArB,CAA6BY,KAA7B,IAAsC,CAA1C,EAA6C;AAC3C,aAAO,KAAP;AACD;AACF;;AACD,SAAO,IAAP;AACD,C,CAED;AACA;;;AACA,IAAMC,oBAAoB,GAAG,CAC3B;AACA,IAF2B,EAG3B;AACA,IAJ2B,EAK3B;AACA,GAN2B,EAO3B;AACA,IAR2B,EAS3B;AACA,IAV2B,EAW3B;AACA,IAZ2B,EAa3B;AACA,GAd2B,EAe3B;AACA,IAhB2B,EAiB3B;AACA,GAlB2B,EAmB3B;AACA,IApB2B,EAqB3B;AACA,KAtB2B,EAuB3B;AACA,MAxB2B,EAyB3B;AACA,IA1B2B,EA2B3B;AACA,MA5B2B,CAA7B","sourcesContent":["import parseDate from './parseDate.js'\r\n\r\n// https://hexdocs.pm/xlsxir/number_styles.html\r\nconst BUILT_IN_DATE_NUMBER_FORMAT_IDS = [14,15,16,17,18,19,20,21,22,27,30,36,45,46,47,50,57]\r\n\r\nexport default function getCellValue(value, type, {\r\n\tgetInlineStringValue,\r\n\tgetStyleId,\r\n\tstyles,\r\n\tvalues,\r\n\tproperties,\r\n\toptions\r\n}) {\r\n if (!type) {\r\n // Default cell type is \"n\" (numeric).\r\n // http://www.datypic.com/sc/ooxml/t-ssml_CT_Cell.html\r\n type = 'n'\r\n }\r\n\r\n // Available Excel cell types:\r\n // https://github.com/SheetJS/sheetjs/blob/19620da30be2a7d7b9801938a0b9b1fd3c4c4b00/docbits/52_datatype.md\r\n //\r\n // Some other document (seems to be old):\r\n // http://webapp.docx4java.org/OnlineDemo/ecma376/SpreadsheetML/ST_CellType.html\r\n //\r\n switch (type) {\r\n // If the cell contains formula string.\r\n case 'str':\r\n value = value.trim()\r\n if (value === '') {\r\n value = undefined\r\n }\r\n break\r\n\r\n // If the cell contains an \"inline\" (not \"shared\") string.\r\n case 'inlineStr':\r\n value = getInlineStringValue()\r\n if (value === undefined) {\r\n throw new Error(`Unsupported \"inline string\" cell value structure`) // : ${cellNode.textContent}`)\r\n }\r\n value = value.trim()\r\n if (value === '') {\r\n value = undefined\r\n }\r\n break\r\n\r\n // If the cell contains a \"shared\" string.\r\n // \"Shared\" strings is a way for an Excel editor to reduce\r\n // the file size by storing \"commonly used\" strings in a dictionary\r\n // and then referring to such strings by their index in that dictionary.\r\n case 's':\r\n // If a cell has no value then there's no `<c/>` element for it.\r\n // If a `<c/>` element exists then it's not empty.\r\n // The `<v/>`alue is a key in the \"shared strings\" dictionary of the\r\n // XLSX file, so look it up in the `values` dictionary by the numeric key.\r\n value = values[parseInt(value)]\r\n value = value.trim()\r\n if (value === '') {\r\n value = undefined\r\n }\r\n break\r\n\r\n case 'b':\r\n value = value === '1' ? true : false\r\n break\r\n\r\n // Stub: blank stub cell that is ignored by data processing utilities.\r\n case 'z':\r\n value = undefined\r\n break\r\n\r\n // Error: `value` is a numeric code.\r\n // They also wrote: \"and `w` property stores its common name\".\r\n // It's unclear what they meant by that.\r\n case 'e':\r\n value = decodeError(value)\r\n break\r\n\r\n // Date: a string to be parsed as a date.\r\n // (usually a string in \"ISO 8601\" format)\r\n case 'd':\r\n if (value === undefined) {\r\n break\r\n }\r\n value = new Date(value)\r\n break\r\n\r\n case 'n':\r\n if (value === undefined) {\r\n break\r\n }\r\n value = parseFloat(value)\r\n // XLSX does have \"d\" type for dates, but it's not commonly used.\r\n // Instead, spreadsheets prefer using \"n\" type for dates for some reason.\r\n //\r\n // In such cases, sometimes a \"date\" type could be heuristically detected\r\n // by looking at such numeric value \"format\" and seeing if it's a date-specific one.\r\n // https://github.com/catamphetamine/read-excel-file/issues/3#issuecomment-395770777\r\n //\r\n // The list of generic numeric value \"formats\":\r\n // https://xlsxwriter.readthedocs.io/format.html#format-set-num-format\r\n //\r\n const styleId = getStyleId()\r\n if (styleId) {\r\n // styleId = parseInt(styleId)\r\n const style = styles[styleId]\r\n if (!style) {\r\n throw new Error(`Cell style not found: ${styleId}`)\r\n }\r\n if (BUILT_IN_DATE_NUMBER_FORMAT_IDS.indexOf(parseInt(style.numberFormat.id)) >= 0 ||\r\n (options.dateFormat && style.numberFormat.template === options.dateFormat) ||\r\n (options.smartDateParser !== false && style.numberFormat.template && isDateTemplate(style.numberFormat.template))) {\r\n value = parseDate(value, properties)\r\n }\r\n }\r\n break\r\n\r\n default:\r\n throw new TypeError(`Cell type not supported: ${type}`)\r\n }\r\n\r\n // Convert empty values to `null`.\r\n if (value === undefined) {\r\n value = null\r\n }\r\n\r\n return value\r\n}\r\n\r\n// Decodes numeric error code to a string code.\r\n// https://github.com/SheetJS/sheetjs/blob/19620da30be2a7d7b9801938a0b9b1fd3c4c4b00/docbits/52_datatype.md\r\nfunction decodeError(errorCode) {\r\n // While the error values are determined by the application,\r\n // the following are some example error values that could be used:\r\n switch (errorCode) {\r\n case 0x00:\r\n return '#NULL!'\r\n case 0x07:\r\n return '#DIV/0!'\r\n case 0x0F:\r\n return '#VALUE!'\r\n case 0x17:\r\n return '#REF!'\r\n case 0x1D:\r\n return '#NAME?'\r\n case 0x24:\r\n return '#NUM!'\r\n case 0x2A:\r\n return '#N/A'\r\n case 0x2B:\r\n return '#GETTING_DATA'\r\n default:\r\n // Such error code doesn't exist. I made it up.\r\n return `#ERROR_${errorCode}`\r\n }\r\n}\r\n\r\nfunction isDateTemplate(template) {\r\n // Date format tokens could be in upper case or in lower case.\r\n // There seems to be no single standard.\r\n // So lowercase the template first.\r\n template = template.toLowerCase()\r\n const tokens = template.split(/\\W+/)\r\n for (const token of tokens) {\r\n if (DATE_TEMPLATE_TOKENS.indexOf(token) < 0) {\r\n return false\r\n }\r\n }\r\n return true\r\n}\r\n\r\n// These tokens could be in upper case or in lower case.\r\n// There seems to be no single standard, so using lower case.\r\nconst DATE_TEMPLATE_TOKENS = [\r\n // Seconds (min two digits). Example: \"05\".\r\n 'ss',\r\n // Minutes (min two digits). Example: \"05\". Could also be \"Months\". Weird.\r\n 'mm',\r\n // Hours. Example: \"1\".\r\n 'h',\r\n // Hours (min two digits). Example: \"01\".\r\n 'hh',\r\n // \"AM\" part of \"AM/PM\". Lowercased just in case.\r\n 'am',\r\n // \"PM\" part of \"AM/PM\". Lowercased just in case.\r\n 'pm',\r\n // Day. Example: \"1\"\r\n 'd',\r\n // Day (min two digits). Example: \"01\"\r\n 'dd',\r\n // Month (numeric). Example: \"1\".\r\n 'm',\r\n // Month (numeric, min two digits). Example: \"01\". Could also be \"Minutes\". Weird.\r\n 'mm',\r\n // Month (shortened month name). Example: \"Jan\".\r\n 'mmm',\r\n // Month (full month name). Example: \"January\".\r\n 'mmmm',\r\n // Two-digit year. Example: \"20\".\r\n 'yy',\r\n // Full year. Example: \"2020\".\r\n 'yyyy'\r\n];"],"file":"parseCellValue.js"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import parseCell from './parseCell';
|
|
2
|
-
import { getCells, getMergedCells } from '../xml/xlsx';
|
|
1
|
+
import parseCell from './parseCell.js';
|
|
2
|
+
import { getCells, getMergedCells } from '../xml/xlsx.js';
|
|
3
3
|
export default function parseCells(sheet, xml, values, styles, properties, options) {
|
|
4
4
|
var cells = getCells(sheet);
|
|
5
5
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../source/read/parseCells.js"],"names":["parseCell","getCells","getMergedCells","parseCells","sheet","xml","values","styles","properties","options","cells","length","map","node"],"mappings":"AAAA,OAAOA,SAAP,MAAsB,
|
|
1
|
+
{"version":3,"sources":["../../source/read/parseCells.js"],"names":["parseCell","getCells","getMergedCells","parseCells","sheet","xml","values","styles","properties","options","cells","length","map","node"],"mappings":"AAAA,OAAOA,SAAP,MAAsB,gBAAtB;AAEA,SACEC,QADF,EAEEC,cAFF,QAGO,gBAHP;AAKA,eAAe,SAASC,UAAT,CAAoBC,KAApB,EAA2BC,GAA3B,EAAgCC,MAAhC,EAAwCC,MAAxC,EAAgDC,UAAhD,EAA4DC,OAA5D,EAAqE;AAClF,MAAMC,KAAK,GAAGT,QAAQ,CAACG,KAAD,CAAtB;;AAEA,MAAIM,KAAK,CAACC,MAAN,KAAiB,CAArB,EAAwB;AACtB,WAAO,EAAP;AACD,GALiF,CAOlF;AACA;AACA;AACA;AACA;;;AAEA,SAAOD,KAAK,CAACE,GAAN,CAAU,UAACC,IAAD,EAAU;AACzB,WAAOb,SAAS,CAACa,IAAD,EAAOT,KAAP,EAAcC,GAAd,EAAmBC,MAAnB,EAA2BC,MAA3B,EAAmCC,UAAnC,EAA+CC,OAA/C,CAAhB;AACD,GAFM,CAAP;AAGD","sourcesContent":["import parseCell from './parseCell.js'\r\n\r\nimport {\r\n getCells,\r\n getMergedCells\r\n} from '../xml/xlsx.js'\r\n\r\nexport default function parseCells(sheet, xml, values, styles, properties, options) {\r\n const cells = getCells(sheet)\r\n\r\n if (cells.length === 0) {\r\n return []\r\n }\r\n\r\n // const mergedCells = getMergedCells(sheet)\r\n // for (const mergedCell of mergedCells) {\r\n // const [from, to] = mergedCell.split(':').map(parseCellCoordinates)\r\n // console.log('Merged Cell.', 'From:', from, 'To:', to)\r\n // }\r\n\r\n return cells.map((node) => {\r\n return parseCell(node, sheet, xml, values, styles, properties, options)\r\n })\r\n}"],"file":"parseCells.js"}
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
// Parses an Excel Date ("serial") into a
|
|
2
|
-
// corresponding javascript Date in UTC+0 timezone.
|
|
1
|
+
// Parses an Excel Date ("serial") into a corresponding javascript Date in UTC+0 timezone.
|
|
3
2
|
// (with time equal to 00:00)
|
|
4
3
|
//
|
|
5
|
-
// Doesn't account for leap seconds.
|
|
6
|
-
// Therefore is not 100% correct.
|
|
7
|
-
// But will do, I guess, since we're
|
|
8
|
-
// not doing rocket science here.
|
|
9
|
-
//
|
|
10
4
|
// https://www.pcworld.com/article/3063622/software/mastering-excel-date-time-serial-numbers-networkdays-datevalue-and-more.html
|
|
11
5
|
// "If you need to calculate dates in your spreadsheets,
|
|
12
6
|
// Excel uses its own unique system, which it calls Serial Numbers".
|
|
@@ -27,7 +21,44 @@ export default function parseExcelDate(excelSerialDate, options) {
|
|
|
27
21
|
|
|
28
22
|
|
|
29
23
|
var daysBeforeUnixEpoch = 70 * 365 + 19; // An hour, approximately, because a minute
|
|
30
|
-
// may be longer than 60 seconds,
|
|
24
|
+
// may be longer than 60 seconds, due to "leap seconds".
|
|
25
|
+
//
|
|
26
|
+
// Still, Javascript `Date` (and UNIX time in general) intentionally
|
|
27
|
+
// drops the concept of "leap seconds" in order to make things simpler.
|
|
28
|
+
// So it's fine.
|
|
29
|
+
// https://stackoverflow.com/questions/53019726/where-are-the-leap-seconds-in-javascript
|
|
30
|
+
//
|
|
31
|
+
// "The JavaScript Date object specifically adheres to the concept of Unix Time
|
|
32
|
+
// (albeit with higher precision). This is part of the POSIX specification,
|
|
33
|
+
// and thus is sometimes called "POSIX Time". It does not count leap seconds,
|
|
34
|
+
// but rather assumes every day had exactly 86,400 seconds. You can read about
|
|
35
|
+
// this in section 20.3.1.1 of the current ECMAScript specification, which states:
|
|
36
|
+
//
|
|
37
|
+
// "Time is measured in ECMAScript in milliseconds since 01 January, 1970 UTC.
|
|
38
|
+
// In time values leap seconds are ignored. It is assumed that there are exactly
|
|
39
|
+
// 86,400,000 milliseconds per day."
|
|
40
|
+
//
|
|
41
|
+
// The fact is, that the unpredictable nature of leap seconds makes them very
|
|
42
|
+
// difficult to work with in APIs. One can't generally pass timestamps around
|
|
43
|
+
// that need leap seconds tables to be interpreted correctly, and expect that
|
|
44
|
+
// one system will interpret them the same as another. For example, while your
|
|
45
|
+
// example timestamp 1483228826 is 2017-01-01T00:00:00Z on your system,
|
|
46
|
+
// it would be interpreted as 2017-01-01T00:00:26Z on POSIX based systems,
|
|
47
|
+
// or systems without leap second tables. So they aren't portable.
|
|
48
|
+
// Even on systems that have full updated tables, there's no telling what those
|
|
49
|
+
// tables will contain in the future (beyond the 6-month IERS announcement period),
|
|
50
|
+
// so I can't produce a future timestamp without risk that it may eventually change.
|
|
51
|
+
//
|
|
52
|
+
// To be clear - to support leap seconds in a programming language, the implementation
|
|
53
|
+
// must go out of its way to do so, and must make tradeoffs that are not always acceptable.
|
|
54
|
+
// Though there are exceptions, the general position is to not support them - not because
|
|
55
|
+
// of any subversion or active countermeasures, but because supporting them properly is much,
|
|
56
|
+
// much harder."
|
|
57
|
+
//
|
|
58
|
+
// https://en.wikipedia.org/wiki/Unix_time#Leap_seconds
|
|
59
|
+
// https://en.wikipedia.org/wiki/Leap_year
|
|
60
|
+
// https://en.wikipedia.org/wiki/Leap_second
|
|
61
|
+
//
|
|
31
62
|
|
|
32
63
|
var hour = 60 * 60 * 1000;
|
|
33
64
|
return new Date(Math.round((excelSerialDate - daysBeforeUnixEpoch) * 24 * hour));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../source/read/parseDate.js"],"names":["parseExcelDate","excelSerialDate","options","epoch1904","daysBeforeUnixEpoch","hour","Date","Math","round"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../source/read/parseDate.js"],"names":["parseExcelDate","excelSerialDate","options","epoch1904","daysBeforeUnixEpoch","hour","Date","Math","round"],"mappings":"AAAI;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASA,cAAT,CAAwBC,eAAxB,EAAyCC,OAAzC,EAAkD;AAC/D;AACA,MAAIA,OAAO,IAAIA,OAAO,CAACC,SAAvB,EAAkC;AAChCF,IAAAA,eAAe,IAAI,IAAnB;AACD,GAJ8D,CAM/D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,MAAMG,mBAAmB,GAAG,KAAK,GAAL,GAAW,EAAvC,CAf+D,CAiB/D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,IAAI,GAAG,KAAK,EAAL,GAAU,IAAvB;AAEA,SAAO,IAAIC,IAAJ,CAASC,IAAI,CAACC,KAAL,CAAW,CAACP,eAAe,GAAGG,mBAAnB,IAA0C,EAA1C,GAA+CC,IAA1D,CAAT,CAAP;AACD","sourcesContent":[" // Parses an Excel Date (\"serial\") into a corresponding javascript Date in UTC+0 timezone.\r\n // (with time equal to 00:00)\r\n //\r\n // https://www.pcworld.com/article/3063622/software/mastering-excel-date-time-serial-numbers-networkdays-datevalue-and-more.html\r\n // \"If you need to calculate dates in your spreadsheets,\r\n // Excel uses its own unique system, which it calls Serial Numbers\".\r\n //\r\n export default function parseExcelDate(excelSerialDate, options) {\r\n // https://support.microsoft.com/en-gb/help/214330/differences-between-the-1900-and-the-1904-date-system-in-excel\r\n if (options && options.epoch1904) {\r\n excelSerialDate += 1462\r\n }\r\n\r\n // \"Excel serial date\" is just\r\n // the count of days since `01/01/1900`\r\n // (seems that it may be even fractional).\r\n //\r\n // The count of days elapsed\r\n // since `01/01/1900` (Excel epoch)\r\n // till `01/01/1970` (Unix epoch).\r\n // Accounts for leap years\r\n // (19 of them, yielding 19 extra days).\r\n const daysBeforeUnixEpoch = 70 * 365 + 19\r\n\r\n // An hour, approximately, because a minute\r\n // may be longer than 60 seconds, due to \"leap seconds\".\r\n //\r\n // Still, Javascript `Date` (and UNIX time in general) intentionally\r\n // drops the concept of \"leap seconds\" in order to make things simpler.\r\n // So it's fine.\r\n // https://stackoverflow.com/questions/53019726/where-are-the-leap-seconds-in-javascript\r\n //\r\n // \"The JavaScript Date object specifically adheres to the concept of Unix Time\r\n // (albeit with higher precision). This is part of the POSIX specification,\r\n // and thus is sometimes called \"POSIX Time\". It does not count leap seconds,\r\n // but rather assumes every day had exactly 86,400 seconds. You can read about\r\n // this in section 20.3.1.1 of the current ECMAScript specification, which states:\r\n //\r\n // \"Time is measured in ECMAScript in milliseconds since 01 January, 1970 UTC.\r\n // In time values leap seconds are ignored. It is assumed that there are exactly\r\n // 86,400,000 milliseconds per day.\"\r\n //\r\n // The fact is, that the unpredictable nature of leap seconds makes them very\r\n // difficult to work with in APIs. One can't generally pass timestamps around\r\n // that need leap seconds tables to be interpreted correctly, and expect that\r\n // one system will interpret them the same as another. For example, while your\r\n // example timestamp 1483228826 is 2017-01-01T00:00:00Z on your system,\r\n // it would be interpreted as 2017-01-01T00:00:26Z on POSIX based systems,\r\n // or systems without leap second tables. So they aren't portable.\r\n // Even on systems that have full updated tables, there's no telling what those\r\n // tables will contain in the future (beyond the 6-month IERS announcement period),\r\n // so I can't produce a future timestamp without risk that it may eventually change.\r\n //\r\n // To be clear - to support leap seconds in a programming language, the implementation\r\n // must go out of its way to do so, and must make tradeoffs that are not always acceptable.\r\n // Though there are exceptions, the general position is to not support them - not because\r\n // of any subversion or active countermeasures, but because supporting them properly is much,\r\n // much harder.\"\r\n //\r\n // https://en.wikipedia.org/wiki/Unix_time#Leap_seconds\r\n // https://en.wikipedia.org/wiki/Leap_year\r\n // https://en.wikipedia.org/wiki/Leap_second\r\n //\r\n const hour = 60 * 60 * 1000\r\n\r\n return new Date(Math.round((excelSerialDate - daysBeforeUnixEpoch) * 24 * hour))\r\n }"],"file":"parseDate.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../source/read/parseDate.test.js"],"names":["parseDate","describe","it","date","convertToUTCTimezone","Date","getTime","should","equal","getTimezoneOffset"],"mappings":"AAAA,OAAOA,SAAP,MAAsB,
|
|
1
|
+
{"version":3,"sources":["../../source/read/parseDate.test.js"],"names":["parseDate","describe","it","date","convertToUTCTimezone","Date","getTime","should","equal","getTimezoneOffset"],"mappings":"AAAA,OAAOA,SAAP,MAAsB,gBAAtB;AAEAC,QAAQ,CAAC,WAAD,EAAc,YAAM;AAC3BC,EAAAA,EAAE,CAAC,mCAAD,EAAsC,YAAM;AAC7C,QAAMC,IAAI,GAAGC,oBAAoB,CAAC,IAAIC,IAAJ,CAAS,IAAT,EAAe,IAAI,CAAnB,EAAsB,EAAtB,CAAD,CAAjC,CAD6C,CAE3C;AACA;;AACFL,IAAAA,SAAS,CAAC,KAAD,CAAT,CAAiBM,OAAjB,GAA2BC,MAA3B,CAAkCC,KAAlC,CAAwCL,IAAI,CAACG,OAAL,EAAxC;AACA,GALC,CAAF;AAMA,CAPO,CAAR,C,CASA;;AACA,SAASF,oBAAT,CAA8BD,IAA9B,EAAoC;AACnC;AACA;AACA;AACA;AACA;AACA;AACA,SAAO,IAAIE,IAAJ,CAASF,IAAI,CAACG,OAAL,KAAiBH,IAAI,CAACM,iBAAL,KAA2B,EAA3B,GAAgC,IAA1D,CAAP;AACA","sourcesContent":["import parseDate from './parseDate.js'\r\n\r\ndescribe('parseDate', () => {\r\n\tit('should parse Excel \"serial\" dates', () => {\r\n\t\tconst date = convertToUTCTimezone(new Date(2018, 3 - 1, 24))\r\n // Excel stores dates as integers.\r\n // E.g. '24/03/2018' === 43183\r\n\t\tparseDate(43183).getTime().should.equal(date.getTime())\r\n\t})\r\n})\r\n\r\n// Converts timezone to UTC while preserving the same time\r\nfunction convertToUTCTimezone(date) {\r\n\t// Doesn't account for leap seconds but I guess that's ok\r\n\t// given that javascript's own `Date()` does not either.\r\n\t// https://www.timeanddate.com/time/leap-seconds-background.html\r\n\t//\r\n\t// https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset\r\n\t//\r\n\treturn new Date(date.getTime() - date.getTimezoneOffset() * 60 * 1000)\r\n}\r\n"],"file":"parseDate.test.js"}
|
|
@@ -10,8 +10,8 @@ function _iterableToArrayLimit(arr, i) { var _i = arr && (typeof Symbol !== "und
|
|
|
10
10
|
|
|
11
11
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
12
|
|
|
13
|
-
import { parseCellCoordinates } from './coordinates';
|
|
14
|
-
import { getDimensions } from '../xml/xlsx'; // `dimensions` defines the spreadsheet area containing all non-empty cells.
|
|
13
|
+
import { parseCellCoordinates } from './coordinates.js';
|
|
14
|
+
import { getDimensions } from '../xml/xlsx.js'; // `dimensions` defines the spreadsheet area containing all non-empty cells.
|
|
15
15
|
// https://docs.microsoft.com/en-us/dotnet/api/documentformat.openxml.spreadsheet.sheetdimension?view=openxml-2.8.1
|
|
16
16
|
|
|
17
17
|
export default function parseDimensions(sheet) {
|
|
@@ -27,8 +27,13 @@ export default function parseDimensions(sheet) {
|
|
|
27
27
|
row: row,
|
|
28
28
|
column: column
|
|
29
29
|
};
|
|
30
|
-
}); //
|
|
31
|
-
//
|
|
30
|
+
}); // Sometimes there can be just a single cell as a spreadsheet's "dimensions".
|
|
31
|
+
// For example, the default "dimensions" in Apache POI library is "A1",
|
|
32
|
+
// meaning that only the first cell in the spreadsheet is used.
|
|
33
|
+
//
|
|
34
|
+
// A quote from Apache POI library:
|
|
35
|
+
// "Single cell ranges are formatted like single cell references (e.g. 'A1' instead of 'A1:A1')."
|
|
36
|
+
//
|
|
32
37
|
|
|
33
38
|
if (dimensions.length === 1) {
|
|
34
39
|
dimensions = [dimensions[0], dimensions[0]];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../source/read/parseDimensions.js"],"names":["parseCellCoordinates","getDimensions","parseDimensions","sheet","dimensions","split","map","row","column","length"],"mappings":";;;;;;;;;;;;AAAA,SACEA,oBADF,QAEO,
|
|
1
|
+
{"version":3,"sources":["../../source/read/parseDimensions.js"],"names":["parseCellCoordinates","getDimensions","parseDimensions","sheet","dimensions","split","map","row","column","length"],"mappings":";;;;;;;;;;;;AAAA,SACEA,oBADF,QAEO,kBAFP;AAIA,SACEC,aADF,QAEO,gBAFP,C,CAIA;AACA;;AACA,eAAe,SAASC,eAAT,CAAyBC,KAAzB,EAAgC;AAC7C,MAAIC,UAAU,GAAGH,aAAa,CAACE,KAAD,CAA9B;;AACA,MAAIC,UAAJ,EAAgB;AACdA,IAAAA,UAAU,GAAGA,UAAU,CAACC,KAAX,CAAiB,GAAjB,EAAsBC,GAAtB,CAA0BN,oBAA1B,EAAgDM,GAAhD,CAAoD;AAAA;AAAA,UAAEC,GAAF;AAAA,UAAOC,MAAP;;AAAA,aAAoB;AACnFD,QAAAA,GAAG,EAAHA,GADmF;AAEnFC,QAAAA,MAAM,EAANA;AAFmF,OAApB;AAAA,KAApD,CAAb,CADc,CAKd;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,QAAIJ,UAAU,CAACK,MAAX,KAAsB,CAA1B,EAA6B;AAC3BL,MAAAA,UAAU,GAAG,CAACA,UAAU,CAAC,CAAD,CAAX,EAAgBA,UAAU,CAAC,CAAD,CAA1B,CAAb;AACD;;AACD,WAAOA,UAAP;AACD;AACF","sourcesContent":["import {\r\n parseCellCoordinates\r\n} from './coordinates.js'\r\n\r\nimport {\r\n getDimensions\r\n} from '../xml/xlsx.js'\r\n\r\n// `dimensions` defines the spreadsheet area containing all non-empty cells.\r\n// https://docs.microsoft.com/en-us/dotnet/api/documentformat.openxml.spreadsheet.sheetdimension?view=openxml-2.8.1\r\nexport default function parseDimensions(sheet) {\r\n let dimensions = getDimensions(sheet)\r\n if (dimensions) {\r\n dimensions = dimensions.split(':').map(parseCellCoordinates).map(([row, column]) => ({\r\n row,\r\n column\r\n }))\r\n // Sometimes there can be just a single cell as a spreadsheet's \"dimensions\".\r\n // For example, the default \"dimensions\" in Apache POI library is \"A1\",\r\n // meaning that only the first cell in the spreadsheet is used.\r\n //\r\n // A quote from Apache POI library:\r\n // \"Single cell ranges are formatted like single cell references (e.g. 'A1' instead of 'A1:A1').\"\r\n //\r\n if (dimensions.length === 1) {\r\n dimensions = [dimensions[0], dimensions[0]]\r\n }\r\n return dimensions\r\n }\r\n}\r\n\r\n"],"file":"parseDimensions.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../source/read/parseFilePaths.js"],"names":["getRelationships","parseFilePaths","content","xml","document","createDocument","filePaths","sheets","sharedStrings","undefined","styles","addFilePathInfo","relationship","filePath","getAttribute","fileType","getFilePath","forEach","path","slice","length"],"mappings":"AAAA,SACEA,gBADF,QAEO,
|
|
1
|
+
{"version":3,"sources":["../../source/read/parseFilePaths.js"],"names":["getRelationships","parseFilePaths","content","xml","document","createDocument","filePaths","sheets","sharedStrings","undefined","styles","addFilePathInfo","relationship","filePath","getAttribute","fileType","getFilePath","forEach","path","slice","length"],"mappings":"AAAA,SACEA,gBADF,QAEO,gBAFP;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,cAAT,CAAwBC,OAAxB,EAAiCC,GAAjC,EAAsC;AACnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,QAAQ,GAAGD,GAAG,CAACE,cAAJ,CAAmBH,OAAnB,CAAjB;AAEA,MAAMI,SAAS,GAAG;AAChBC,IAAAA,MAAM,EAAE,EADQ;AAEhBC,IAAAA,aAAa,EAAEC,SAFC;AAGhBC,IAAAA,MAAM,EAAED;AAHQ,GAAlB;;AAMA,MAAME,eAAe,GAAG,SAAlBA,eAAkB,CAACC,YAAD,EAAkB;AACxC,QAAMC,QAAQ,GAAGD,YAAY,CAACE,YAAb,CAA0B,QAA1B,CAAjB;AACA,QAAMC,QAAQ,GAAGH,YAAY,CAACE,YAAb,CAA0B,MAA1B,CAAjB;;AACA,YAAQC,QAAR;AACE,WAAK,4EAAL;AACET,QAAAA,SAAS,CAACI,MAAV,GAAmBM,WAAW,CAACH,QAAD,CAA9B;AACA;;AACF,WAAK,mFAAL;AACEP,QAAAA,SAAS,CAACE,aAAV,GAA0BQ,WAAW,CAACH,QAAD,CAArC;AACA;;AACF,WAAK,+EAAL;AACEP,QAAAA,SAAS,CAACC,MAAV,CAAiBK,YAAY,CAACE,YAAb,CAA0B,IAA1B,CAAjB,IAAoDE,WAAW,CAACH,QAAD,CAA/D;AACA;AATJ;AAWD,GAdD;;AAgBAb,EAAAA,gBAAgB,CAACI,QAAD,CAAhB,CAA2Ba,OAA3B,CAAmCN,eAAnC,EAjCmD,CAmCnD;AACA;AACA;AACA;AACA;AACA;;AAEA,SAAOL,SAAP;AACD;;AAED,SAASU,WAAT,CAAqBE,IAArB,EAA2B;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAIA,IAAI,CAAC,CAAD,CAAJ,KAAY,GAAhB,EAAqB;AACnB,WAAOA,IAAI,CAACC,KAAL,CAAW,IAAIC,MAAf,CAAP;AACD,GAVwB,CAWzB;AACA;AACA;AACA;AACA;;;AACA,SAAO,QAAQF,IAAf;AACD","sourcesContent":["import {\r\n getRelationships\r\n} from '../xml/xlsx.js'\r\n\r\n/**\r\n * Returns sheet file paths.\r\n * Seems that the correct place to look for the `sheetId` -> `filename` mapping\r\n * is `xl/_rels/workbook.xml.rels` file.\r\n * https://github.com/tidyverse/readxl/issues/104\r\n * @param {string} content — `xl/_rels/workbook.xml.rels` file contents.\r\n * @param {object} xml\r\n * @return {object}\r\n */\r\nexport default function parseFilePaths(content, xml) {\r\n // Example:\r\n // <Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">\r\n // ...\r\n // <Relationship\r\n // Id=\"rId3\"\r\n // Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet\"\r\n // Target=\"worksheets/sheet1.xml\"/>\r\n // </Relationships>\r\n const document = xml.createDocument(content)\r\n\r\n const filePaths = {\r\n sheets: {},\r\n sharedStrings: undefined,\r\n styles: undefined\r\n }\r\n\r\n const addFilePathInfo = (relationship) => {\r\n const filePath = relationship.getAttribute('Target')\r\n const fileType = relationship.getAttribute('Type')\r\n switch (fileType) {\r\n case 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles':\r\n filePaths.styles = getFilePath(filePath)\r\n break\r\n case 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings':\r\n filePaths.sharedStrings = getFilePath(filePath)\r\n break\r\n case 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet':\r\n filePaths.sheets[relationship.getAttribute('Id')] = getFilePath(filePath)\r\n break\r\n }\r\n }\r\n\r\n getRelationships(document).forEach(addFilePathInfo)\r\n\r\n // Seems like \"sharedStrings.xml\" is not required to exist.\r\n // For example, when the spreadsheet doesn't contain any strings.\r\n // https://github.com/catamphetamine/read-excel-file/issues/85\r\n // if (!filePaths.sharedStrings) {\r\n // throw new Error('\"sharedStrings.xml\" file not found in the *.xlsx file')\r\n // }\r\n\r\n return filePaths\r\n}\r\n\r\nfunction getFilePath(path) {\r\n // Normally, `path` is a relative path inside the ZIP archive,\r\n // like \"worksheets/sheet1.xml\", or \"sharedStrings.xml\", or \"styles.xml\".\r\n // There has been one weird case when file path was an absolute path,\r\n // like \"/xl/worksheets/sheet1.xml\" (specifically for sheets):\r\n // https://github.com/catamphetamine/read-excel-file/pull/95\r\n // Other libraries (like `xlsx`) and software (like Google Docs)\r\n // seem to support such absolute file paths, so this library does too.\r\n if (path[0] === '/') {\r\n return path.slice('/'.length)\r\n }\r\n // // Seems like a path could also be a URL.\r\n // // http://officeopenxml.com/anatomyofOOXML-xlsx.php\r\n // if (/^[a-z]+\\:\\/\\//.test(path)) {\r\n // return path\r\n // }\r\n return 'xl/' + path\r\n}"],"file":"parseFilePaths.js"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getWorkbookProperties, getSheets } from '../xml/xlsx'; // I guess `xl/workbook.xml` file should always be present inside the *.xlsx archive.
|
|
1
|
+
import { getWorkbookProperties, getSheets } from '../xml/xlsx.js'; // I guess `xl/workbook.xml` file should always be present inside the *.xlsx archive.
|
|
2
2
|
|
|
3
3
|
export default function parseProperties(content, xml) {
|
|
4
4
|
var book = xml.createDocument(content);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../source/read/parseProperties.js"],"names":["getWorkbookProperties","getSheets","parseProperties","content","xml","book","createDocument","properties","workbookProperties","getAttribute","epoch1904","sheets","addSheetInfo","sheet","push","id","name","relationId","forEach"],"mappings":"AAAA,SACEA,qBADF,EAEEC,SAFF,QAGO,
|
|
1
|
+
{"version":3,"sources":["../../source/read/parseProperties.js"],"names":["getWorkbookProperties","getSheets","parseProperties","content","xml","book","createDocument","properties","workbookProperties","getAttribute","epoch1904","sheets","addSheetInfo","sheet","push","id","name","relationId","forEach"],"mappings":"AAAA,SACEA,qBADF,EAEEC,SAFF,QAGO,gBAHP,C,CAKA;;AACA,eAAe,SAASC,eAAT,CAAyBC,OAAzB,EAAkCC,GAAlC,EAAuC;AACpD,MAAMC,IAAI,GAAGD,GAAG,CAACE,cAAJ,CAAmBH,OAAnB,CAAb;AAEA,MAAMI,UAAU,GAAG,EAAnB,CAHoD,CAKpD;AACA;AACA;;AAEA,MAAMC,kBAAkB,GAAGR,qBAAqB,CAACK,IAAD,CAAhD;;AAEA,MAAIG,kBAAkB,IAAIA,kBAAkB,CAACC,YAAnB,CAAgC,UAAhC,MAAgD,GAA1E,EAA+E;AAC7EF,IAAAA,UAAU,CAACG,SAAX,GAAuB,IAAvB;AACD,GAbmD,CAepD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAEAH,EAAAA,UAAU,CAACI,MAAX,GAAoB,EAApB;;AAEA,MAAMC,YAAY,GAAG,SAAfA,YAAe,CAACC,KAAD,EAAW;AAC9B,QAAIA,KAAK,CAACJ,YAAN,CAAmB,MAAnB,CAAJ,EAAgC;AAC9BF,MAAAA,UAAU,CAACI,MAAX,CAAkBG,IAAlB,CAAuB;AACrBC,QAAAA,EAAE,EAAEF,KAAK,CAACJ,YAAN,CAAmB,SAAnB,CADiB;AAErBO,QAAAA,IAAI,EAAEH,KAAK,CAACJ,YAAN,CAAmB,MAAnB,CAFe;AAGrBQ,QAAAA,UAAU,EAAEJ,KAAK,CAACJ,YAAN,CAAmB,MAAnB;AAHS,OAAvB;AAKD;AACF,GARD;;AAUAR,EAAAA,SAAS,CAACI,IAAD,CAAT,CAAgBa,OAAhB,CAAwBN,YAAxB;AAEA,SAAOL,UAAP;AACD","sourcesContent":["import {\r\n getWorkbookProperties,\r\n getSheets\r\n} from '../xml/xlsx.js'\r\n\r\n// I guess `xl/workbook.xml` file should always be present inside the *.xlsx archive.\r\nexport default function parseProperties(content, xml) {\r\n const book = xml.createDocument(content)\r\n\r\n const properties = {};\r\n\r\n // Read `<workbookPr/>` element to detect whether dates are 1900-based or 1904-based.\r\n // https://support.microsoft.com/en-gb/help/214330/differences-between-the-1900-and-the-1904-date-system-in-excel\r\n // http://webapp.docx4java.org/OnlineDemo/ecma376/SpreadsheetML/workbookPr.html\r\n\r\n const workbookProperties = getWorkbookProperties(book)\r\n\r\n if (workbookProperties && workbookProperties.getAttribute('date1904') === '1') {\r\n properties.epoch1904 = true\r\n }\r\n\r\n // Get sheets info (indexes, names, if they're available).\r\n // Example:\r\n // <sheets>\r\n // <sheet\r\n // xmlns:ns=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"\r\n // name=\"Sheet1\"\r\n // sheetId=\"1\"\r\n // ns:id=\"rId3\"/>\r\n // </sheets>\r\n // http://www.datypic.com/sc/ooxml/e-ssml_sheet-1.html\r\n\r\n properties.sheets = []\r\n\r\n const addSheetInfo = (sheet) => {\r\n if (sheet.getAttribute('name')) {\r\n properties.sheets.push({\r\n id: sheet.getAttribute('sheetId'),\r\n name: sheet.getAttribute('name'),\r\n relationId: sheet.getAttribute('r:id')\r\n })\r\n }\r\n }\r\n\r\n getSheets(book).forEach(addSheetInfo)\r\n\r\n return properties;\r\n}"],"file":"parseProperties.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../source/read/parseSharedStrings.js"],"names":["getSharedStrings","parseSharedStrings","content","xml","createDocument"],"mappings":"AAAA,SACEA,gBADF,QAEO,
|
|
1
|
+
{"version":3,"sources":["../../source/read/parseSharedStrings.js"],"names":["getSharedStrings","parseSharedStrings","content","xml","createDocument"],"mappings":"AAAA,SACEA,gBADF,QAEO,gBAFP;AAIA,eAAe,SAASC,kBAAT,CAA4BC,OAA5B,EAAqCC,GAArC,EAA0C;AACvD,MAAI,CAACD,OAAL,EAAc;AACZ,WAAO,EAAP;AACD;;AACD,SAAOF,gBAAgB,CAACG,GAAG,CAACC,cAAJ,CAAmBF,OAAnB,CAAD,CAAvB;AACD","sourcesContent":["import {\r\n getSharedStrings\r\n} from '../xml/xlsx.js'\r\n\r\nexport default function parseSharedStrings(content, xml) {\r\n if (!content) {\r\n return []\r\n }\r\n return getSharedStrings(xml.createDocument(content))\r\n}"],"file":"parseSharedStrings.js"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import parseCells from './parseCells';
|
|
2
|
-
import parseDimensions from './parseDimensions';
|
|
3
|
-
import { calculateDimensions } from './coordinates';
|
|
1
|
+
import parseCells from './parseCells.js';
|
|
2
|
+
import parseDimensions from './parseDimensions.js';
|
|
3
|
+
import { calculateDimensions } from './coordinates.js';
|
|
4
4
|
export default function parseSheet(content, xml, values, styles, properties, options) {
|
|
5
5
|
var sheet = xml.createDocument(content);
|
|
6
6
|
var cells = parseCells(sheet, xml, values, styles, properties, options); // `dimensions` defines the spreadsheet area containing all non-empty cells.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../source/read/parseSheet.js"],"names":["parseCells","parseDimensions","calculateDimensions","parseSheet","content","xml","values","styles","properties","options","sheet","createDocument","cells","dimensions"],"mappings":"AAAA,OAAOA,UAAP,MAAuB,
|
|
1
|
+
{"version":3,"sources":["../../source/read/parseSheet.js"],"names":["parseCells","parseDimensions","calculateDimensions","parseSheet","content","xml","values","styles","properties","options","sheet","createDocument","cells","dimensions"],"mappings":"AAAA,OAAOA,UAAP,MAAuB,iBAAvB;AACA,OAAOC,eAAP,MAA4B,sBAA5B;AAEA,SAASC,mBAAT,QAAoC,kBAApC;AAEA,eAAe,SAASC,UAAT,CAAoBC,OAApB,EAA6BC,GAA7B,EAAkCC,MAAlC,EAA0CC,MAA1C,EAAkDC,UAAlD,EAA8DC,OAA9D,EAAuE;AACpF,MAAMC,KAAK,GAAGL,GAAG,CAACM,cAAJ,CAAmBP,OAAnB,CAAd;AAEA,MAAMQ,KAAK,GAAGZ,UAAU,CAACU,KAAD,EAAQL,GAAR,EAAaC,MAAb,EAAqBC,MAArB,EAA6BC,UAA7B,EAAyCC,OAAzC,CAAxB,CAHoF,CAKpF;AACA;;AACA,MAAMI,UAAU,GAAGZ,eAAe,CAACS,KAAD,CAAf,IAA0BR,mBAAmB,CAACU,KAAD,CAAhE;AAEA,SAAO;AAAEA,IAAAA,KAAK,EAALA,KAAF;AAASC,IAAAA,UAAU,EAAVA;AAAT,GAAP;AACD","sourcesContent":["import parseCells from './parseCells.js'\r\nimport parseDimensions from './parseDimensions.js'\r\n\r\nimport { calculateDimensions } from './coordinates.js'\r\n\r\nexport default function parseSheet(content, xml, values, styles, properties, options) {\r\n const sheet = xml.createDocument(content)\r\n\r\n const cells = parseCells(sheet, xml, values, styles, properties, options)\r\n\r\n // `dimensions` defines the spreadsheet area containing all non-empty cells.\r\n // https://docs.microsoft.com/en-us/dotnet/api/documentformat.openxml.spreadsheet.sheetdimension?view=openxml-2.8.1\r\n const dimensions = parseDimensions(sheet) || calculateDimensions(cells)\r\n\r\n return { cells, dimensions }\r\n}"],"file":"parseSheet.js"}
|
|
@@ -4,7 +4,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
4
4
|
|
|
5
5
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
6
|
|
|
7
|
-
import { getBaseStyles, getCellStyles, getNumberFormats } from '../xml/xlsx'; // http://officeopenxml.com/SSstyles.php
|
|
7
|
+
import { getBaseStyles, getCellStyles, getNumberFormats } from '../xml/xlsx.js'; // http://officeopenxml.com/SSstyles.php
|
|
8
8
|
// Returns an array of cell styles.
|
|
9
9
|
// A cell style index is its ID.
|
|
10
10
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../source/read/parseStyles.js"],"names":["getBaseStyles","getCellStyles","getNumberFormats","parseStyles","content","xml","doc","createDocument","baseStyles","map","parseCellStyle","numberFormats","parseNumberFormatStyle","reduce","formats","format","id","getCellStyle","xf","hasAttribute","xfId","numFmt","getAttribute","template","numFmts","style","numberFormatId","numberFormat"],"mappings":";;;;;;AAAA,SACEA,aADF,EAEEC,aAFF,EAGEC,gBAHF,QAIO,
|
|
1
|
+
{"version":3,"sources":["../../source/read/parseStyles.js"],"names":["getBaseStyles","getCellStyles","getNumberFormats","parseStyles","content","xml","doc","createDocument","baseStyles","map","parseCellStyle","numberFormats","parseNumberFormatStyle","reduce","formats","format","id","getCellStyle","xf","hasAttribute","xfId","numFmt","getAttribute","template","numFmts","style","numberFormatId","numberFormat"],"mappings":";;;;;;AAAA,SACEA,aADF,EAEEC,aAFF,EAGEC,gBAHF,QAIO,gBAJP,C,CAMA;AACA;AACA;;AACA,eAAe,SAASC,WAAT,CAAqBC,OAArB,EAA8BC,GAA9B,EAAmC;AAChD,MAAI,CAACD,OAAL,EAAc;AACZ,WAAO,EAAP;AACD,GAH+C,CAKhD;AACA;;;AACA,MAAME,GAAG,GAAGD,GAAG,CAACE,cAAJ,CAAmBH,OAAnB,CAAZ;AAEA,MAAMI,UAAU,GAAGR,aAAa,CAACM,GAAD,CAAb,CAChBG,GADgB,CACZC,cADY,CAAnB;AAGA,MAAMC,aAAa,GAAGT,gBAAgB,CAACI,GAAD,CAAhB,CACnBG,GADmB,CACfG,sBADe,EAEnBC,MAFmB,CAEZ,UAACC,OAAD,EAAUC,MAAV,EAAqB;AAC3B;AACA;AACAD,IAAAA,OAAO,CAACC,MAAM,CAACC,EAAR,CAAP,GAAqBD,MAArB;AACA,WAAOD,OAAP;AACD,GAPmB,EAOjB,EAPiB,CAAtB;;AASA,MAAMG,YAAY,GAAG,SAAfA,YAAe,CAACC,EAAD,EAAQ;AAC3B,QAAIA,EAAE,CAACC,YAAH,CAAgB,MAAhB,CAAJ,EAA6B;AAC3B,6CACKX,UAAU,CAACU,EAAE,CAACE,IAAJ,CADf,GAEKV,cAAc,CAACQ,EAAD,EAAKP,aAAL,CAFnB;AAID;;AACD,WAAOD,cAAc,CAACQ,EAAD,EAAKP,aAAL,CAArB;AACD,GARD;;AAUA,SAAOV,aAAa,CAACK,GAAD,CAAb,CAAmBG,GAAnB,CAAuBQ,YAAvB,CAAP;AACD;;AAED,SAASL,sBAAT,CAAgCS,MAAhC,EAAwC;AACtC,SAAO;AACLL,IAAAA,EAAE,EAAEK,MAAM,CAACC,YAAP,CAAoB,UAApB,CADC;AAELC,IAAAA,QAAQ,EAAEF,MAAM,CAACC,YAAP,CAAoB,YAApB;AAFL,GAAP;AAID,C,CAED;;;AACA,SAASZ,cAAT,CAAwBQ,EAAxB,EAA4BM,OAA5B,EAAqC;AACnC,MAAMC,KAAK,GAAG,EAAd;;AACA,MAAIP,EAAE,CAACC,YAAH,CAAgB,UAAhB,CAAJ,EAAiC;AAC/B,QAAMO,cAAc,GAAGR,EAAE,CAACI,YAAH,CAAgB,UAAhB,CAAvB,CAD+B,CAE/B;AACA;;AACA,QAAIE,OAAO,CAACE,cAAD,CAAX,EAA6B;AAC3BD,MAAAA,KAAK,CAACE,YAAN,GAAqBH,OAAO,CAACE,cAAD,CAA5B;AACD,KAFD,MAEO;AACLD,MAAAA,KAAK,CAACE,YAAN,GAAqB;AAAEX,QAAAA,EAAE,EAAEU;AAAN,OAArB;AACD;AACF;;AACD,SAAOD,KAAP;AACD","sourcesContent":["import {\r\n getBaseStyles,\r\n getCellStyles,\r\n getNumberFormats\r\n} from '../xml/xlsx.js'\r\n\r\n// http://officeopenxml.com/SSstyles.php\r\n// Returns an array of cell styles.\r\n// A cell style index is its ID.\r\nexport default function parseStyles(content, xml) {\r\n if (!content) {\r\n return {}\r\n }\r\n\r\n // https://social.msdn.microsoft.com/Forums/sqlserver/en-US/708978af-b598-45c4-a598-d3518a5a09f0/howwhen-is-cellstylexfs-vs-cellxfs-applied-to-a-cell?forum=os_binaryfile\r\n // https://www.office-forums.com/threads/cellxfs-cellstylexfs.2163519/\r\n const doc = xml.createDocument(content)\r\n\r\n const baseStyles = getBaseStyles(doc)\r\n .map(parseCellStyle)\r\n\r\n const numberFormats = getNumberFormats(doc)\r\n .map(parseNumberFormatStyle)\r\n .reduce((formats, format) => {\r\n // Format ID is a numeric index.\r\n // There're some standard \"built-in\" formats (in Excel) up to about `100`.\r\n formats[format.id] = format\r\n return formats\r\n }, [])\r\n\r\n const getCellStyle = (xf) => {\r\n if (xf.hasAttribute('xfId')) {\r\n return {\r\n ...baseStyles[xf.xfId],\r\n ...parseCellStyle(xf, numberFormats)\r\n }\r\n }\r\n return parseCellStyle(xf, numberFormats)\r\n }\r\n\r\n return getCellStyles(doc).map(getCellStyle)\r\n}\r\n\r\nfunction parseNumberFormatStyle(numFmt) {\r\n return {\r\n id: numFmt.getAttribute('numFmtId'),\r\n template: numFmt.getAttribute('formatCode')\r\n }\r\n}\r\n\r\n// http://www.datypic.com/sc/ooxml/e-ssml_xf-2.html\r\nfunction parseCellStyle(xf, numFmts) {\r\n const style = {}\r\n if (xf.hasAttribute('numFmtId')) {\r\n const numberFormatId = xf.getAttribute('numFmtId')\r\n // Built-in number formats don't have a `<numFmt/>` element in `styles.xml`.\r\n // https://hexdocs.pm/xlsxir/number_styles.html\r\n if (numFmts[numberFormatId]) {\r\n style.numberFormat = numFmts[numberFormatId]\r\n } else {\r\n style.numberFormat = { id: numberFormatId }\r\n }\r\n }\r\n return style\r\n}"],"file":"parseStyles.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../source/read/readSheetNamesBrowser.js"],"names":["readXlsxFile","readSheetNames","file","getSheets","then","sheets","map","sheet","name"],"mappings":"AAAA,OAAOA,YAAP,MAAyB,
|
|
1
|
+
{"version":3,"sources":["../../source/read/readSheetNamesBrowser.js"],"names":["readXlsxFile","readSheetNames","file","getSheets","then","sheets","map","sheet","name"],"mappings":"AAAA,OAAOA,YAAP,MAAyB,0BAAzB;AAEA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,cAAT,CAAwBC,IAAxB,EAA8B;AAC5C,SAAOF,YAAY,CAACE,IAAD,EAAO;AAAEC,IAAAA,SAAS,EAAE;AAAb,GAAP,CAAZ,CACLC,IADK,CACA,UAAAC,MAAM;AAAA,WAAIA,MAAM,CAACC,GAAP,CAAW,UAAAC,KAAK;AAAA,aAAIA,KAAK,CAACC,IAAV;AAAA,KAAhB,CAAJ;AAAA,GADN,CAAP;AAEA","sourcesContent":["import readXlsxFile from './readXlsxFileBrowser.js'\r\n\r\n/**\r\n * Reads the list of sheet names in an XLSX file in a web browser.\r\n * @param {file} file - A file being uploaded in the browser.\r\n * @return {Promise} Resolves to an array of objects of shape `{ name: string }`.\r\n */\r\nexport default function readSheetNames(file) {\r\n\treturn readXlsxFile(file, { getSheets: true })\r\n\t\t.then(sheets => sheets.map(sheet => sheet.name))\r\n}"],"file":"readSheetNamesBrowser.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../source/read/readSheetNamesNode.js"],"names":["readXlsxFile","readSheetNames","input","getSheets","then","sheets","map","sheet","name"],"mappings":"AAAA,OAAOA,YAAP,MAAyB,
|
|
1
|
+
{"version":3,"sources":["../../source/read/readSheetNamesNode.js"],"names":["readXlsxFile","readSheetNames","input","getSheets","then","sheets","map","sheet","name"],"mappings":"AAAA,OAAOA,YAAP,MAAyB,uBAAzB;AAEA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,cAAT,CAAwBC,KAAxB,EAA+B;AAC7C,SAAOF,YAAY,CAACE,KAAD,EAAQ;AAAEC,IAAAA,SAAS,EAAE;AAAb,GAAR,CAAZ,CACLC,IADK,CACA,UAAAC,MAAM;AAAA,WAAIA,MAAM,CAACC,GAAP,CAAW,UAAAC,KAAK;AAAA,aAAIA,KAAK,CAACC,IAAV;AAAA,KAAhB,CAAJ;AAAA,GADN,CAAP;AAEA","sourcesContent":["import readXlsxFile from './readXlsxFileNode.js'\r\n\r\n/**\r\n * Reads the list of sheet names in an XLSX file in Node.js.\r\n * @param {(string|Stream|Buffer)} input - A Node.js readable stream or a `Buffer` or a path to a file.\r\n * @return {Promise} Resolves to an array of objects of shape `{ name: string }`.\r\n */\r\nexport default function readSheetNames(input) {\r\n\treturn readXlsxFile(input, { getSheets: true })\r\n\t\t.then(sheets => sheets.map(sheet => sheet.name))\r\n}"],"file":"readSheetNamesNode.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../source/read/readSheetNamesNode.test.js"],"names":["path","readSheetNamesNode","describe","it","resolve","
|
|
1
|
+
{"version":3,"sources":["../../source/read/readSheetNamesNode.test.js"],"names":["path","readSheetNamesNode","describe","it","resolve","then","sheetNames","should","deep","equal"],"mappings":"AAAA,OAAOA,IAAP,MAAiB,MAAjB;AAEA,OAAOC,kBAAP,MAA+B,yBAA/B;AAEAC,QAAQ,CAAC,oBAAD,EAAuB,YAAM;AACpCC,EAAAA,EAAE,CAAC,kEAAD,EAAqE,YAAM;AAC5E,WAAOF,kBAAkB,CAACD,IAAI,CAACI,OAAL,CAAa,0CAAb,CAAD,CAAlB,CAA6EC,IAA7E,CAAkF,UAACC,UAAD,EAAgB;AACxGA,MAAAA,UAAU,CAACC,MAAX,CAAkBC,IAAlB,CAAuBC,KAAvB,CAA6B,CAAC,SAAD,EAAY,SAAZ,CAA7B;AACA,KAFM,CAAP;AAGA,GAJC,CAAF;AAKA,CANO,CAAR","sourcesContent":["import path from 'path'\r\n\r\nimport readSheetNamesNode from './readSheetNamesNode.js'\r\n\r\ndescribe('readSheetNamesNode', () => {\r\n\tit('should read the list of sheet names in an *.xlsx file in Node.js', () => {\r\n\t\treturn readSheetNamesNode(path.resolve('./test/spreadsheets/multiple-sheets.xlsx')).then((sheetNames) => {\r\n\t\t\tsheetNames.should.deep.equal(['sheet 1', 'sheet 2'])\r\n\t\t})\r\n\t})\r\n})"],"file":"readSheetNamesNode.test.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../source/read/readSheetNamesWebWorker.js"],"names":["readXlsxFile","readSheetNames","file","getSheets","then","sheets","map","sheet","name"],"mappings":"AAAA,OAAOA,YAAP,MAAyB,
|
|
1
|
+
{"version":3,"sources":["../../source/read/readSheetNamesWebWorker.js"],"names":["readXlsxFile","readSheetNames","file","getSheets","then","sheets","map","sheet","name"],"mappings":"AAAA,OAAOA,YAAP,MAAyB,4BAAzB;AAEA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,cAAT,CAAwBC,IAAxB,EAA8B;AAC5C,SAAOF,YAAY,CAACE,IAAD,EAAO;AAAEC,IAAAA,SAAS,EAAE;AAAb,GAAP,CAAZ,CACLC,IADK,CACA,UAAAC,MAAM;AAAA,WAAIA,MAAM,CAACC,GAAP,CAAW,UAAAC,KAAK;AAAA,aAAIA,KAAK,CAACC,IAAV;AAAA,KAAhB,CAAJ;AAAA,GADN,CAAP;AAEA","sourcesContent":["import readXlsxFile from './readXlsxFileWebWorker.js'\r\n\r\n/**\r\n * Reads the list of sheet names in an XLSX file in a Web Worker.\r\n * @param {file} file - The file.\r\n * @return {Promise} Resolves to an array of objects of shape `{ name: string }`.\r\n */\r\nexport default function readSheetNames(file) {\r\n\treturn readXlsxFile(file, { getSheets: true })\r\n\t\t.then(sheets => sheets.map(sheet => sheet.name))\r\n}"],"file":"readSheetNamesWebWorker.js"}
|