read-excel-file 5.2.8 → 5.2.9

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.
Files changed (77) hide show
  1. package/bundle/read-excel-file.min.js +2 -2
  2. package/bundle/read-excel-file.min.js.map +1 -1
  3. package/commonjs/read/coordinates.js +56 -0
  4. package/commonjs/read/coordinates.js.map +1 -0
  5. package/commonjs/read/dropEmptyColumns.js +52 -0
  6. package/commonjs/read/dropEmptyColumns.js.map +1 -0
  7. package/commonjs/read/dropEmptyColumns.test.js.map +1 -0
  8. package/commonjs/read/dropEmptyRows.js +55 -0
  9. package/commonjs/read/dropEmptyRows.js.map +1 -0
  10. package/commonjs/read/dropEmptyRows.test.js.map +1 -0
  11. package/commonjs/read/getData.js +99 -0
  12. package/commonjs/read/getData.js.map +1 -0
  13. package/commonjs/read/parseCell.js +71 -0
  14. package/commonjs/read/parseCell.js.map +1 -0
  15. package/commonjs/read/parseCellValue.js +204 -0
  16. package/commonjs/read/parseCellValue.js.map +1 -0
  17. package/commonjs/read/parseCells.js +30 -0
  18. package/commonjs/read/parseCells.js.map +1 -0
  19. package/commonjs/read/parseDimensions.js +47 -0
  20. package/commonjs/read/parseDimensions.js.map +1 -0
  21. package/commonjs/read/parseFilePaths.js +83 -0
  22. package/commonjs/read/parseFilePaths.js.map +1 -0
  23. package/commonjs/read/parseProperties.js +48 -0
  24. package/commonjs/read/parseProperties.js.map +1 -0
  25. package/commonjs/read/parseSharedStrings.js +17 -0
  26. package/commonjs/read/parseSharedStrings.js.map +1 -0
  27. package/commonjs/read/parseSheet.js +25 -0
  28. package/commonjs/read/parseSheet.js.map +1 -0
  29. package/commonjs/read/parseStyles.js +72 -0
  30. package/commonjs/read/parseStyles.js.map +1 -0
  31. package/commonjs/read/readXlsx.js +25 -657
  32. package/commonjs/read/readXlsx.js.map +1 -1
  33. package/commonjs/xml/xlsx-xpath.js +10 -0
  34. package/commonjs/xml/xlsx-xpath.js.map +1 -1
  35. package/commonjs/xml/xlsx.js +18 -3
  36. package/commonjs/xml/xlsx.js.map +1 -1
  37. package/commonjs/xml/xmlNode.js +1 -1
  38. package/commonjs/xml/xmlNode.js.map +1 -1
  39. package/modules/read/coordinates.js +48 -0
  40. package/modules/read/coordinates.js.map +1 -0
  41. package/modules/read/dropEmptyColumns.js +45 -0
  42. package/modules/read/dropEmptyColumns.js.map +1 -0
  43. package/modules/read/dropEmptyColumns.test.js.map +1 -0
  44. package/modules/read/dropEmptyRows.js +48 -0
  45. package/modules/read/dropEmptyRows.js.map +1 -0
  46. package/modules/read/dropEmptyRows.test.js.map +1 -0
  47. package/modules/read/getData.js +88 -0
  48. package/modules/read/getData.js.map +1 -0
  49. package/modules/read/parseCell.js +59 -0
  50. package/modules/read/parseCell.js.map +1 -0
  51. package/modules/read/parseCellValue.js +192 -0
  52. package/modules/read/parseCellValue.js.map +1 -0
  53. package/modules/read/parseCells.js +19 -0
  54. package/modules/read/parseCells.js.map +1 -0
  55. package/modules/read/parseDimensions.js +38 -0
  56. package/modules/read/parseDimensions.js.map +1 -0
  57. package/modules/read/parseFilePaths.js +76 -0
  58. package/modules/read/parseFilePaths.js.map +1 -0
  59. package/modules/read/parseProperties.js +40 -0
  60. package/modules/read/parseProperties.js.map +1 -0
  61. package/modules/read/parseSharedStrings.js +9 -0
  62. package/modules/read/parseSharedStrings.js.map +1 -0
  63. package/modules/read/parseSheet.js +13 -0
  64. package/modules/read/parseSheet.js.map +1 -0
  65. package/modules/read/parseStyles.js +64 -0
  66. package/modules/read/parseStyles.js.map +1 -0
  67. package/modules/read/readXlsx.js +20 -653
  68. package/modules/read/readXlsx.js.map +1 -1
  69. package/modules/xml/xlsx-xpath.js +6 -0
  70. package/modules/xml/xlsx-xpath.js.map +1 -1
  71. package/modules/xml/xlsx.js +16 -3
  72. package/modules/xml/xlsx.js.map +1 -1
  73. package/modules/xml/xmlNode.js +1 -1
  74. package/modules/xml/xmlNode.js.map +1 -1
  75. package/package.json +6 -5
  76. package/commonjs/read/readXlsx.test.js.map +0 -1
  77. package/modules/read/readXlsx.test.js.map +0 -1
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = parseCells;
7
+
8
+ var _parseCell = _interopRequireDefault(require("./parseCell"));
9
+
10
+ var _xlsx = require("../xml/xlsx");
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
13
+
14
+ function parseCells(sheet, xml, values, styles, properties, options) {
15
+ var cells = (0, _xlsx.getCells)(sheet);
16
+
17
+ if (cells.length === 0) {
18
+ return [];
19
+ } // const mergedCells = getMergedCells(sheet)
20
+ // for (const mergedCell of mergedCells) {
21
+ // const [from, to] = mergedCell.split(':').map(parseCellCoordinates)
22
+ // console.log('Merged Cell.', 'From:', from, 'To:', to)
23
+ // }
24
+
25
+
26
+ return cells.map(function (node) {
27
+ return (0, _parseCell["default"])(node, sheet, xml, values, styles, properties, options);
28
+ });
29
+ }
30
+ //# sourceMappingURL=parseCells.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../source/read/parseCells.js"],"names":["parseCells","sheet","xml","values","styles","properties","options","cells","length","map","node"],"mappings":";;;;;;;AAAA;;AAEA;;;;AAKe,SAASA,UAAT,CAAoBC,KAApB,EAA2BC,GAA3B,EAAgCC,MAAhC,EAAwCC,MAAxC,EAAgDC,UAAhD,EAA4DC,OAA5D,EAAqE;AAClF,MAAMC,KAAK,GAAG,oBAASN,KAAT,CAAd;;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,WAAO,2BAAUA,IAAV,EAAgBT,KAAhB,EAAuBC,GAAvB,EAA4BC,MAA5B,EAAoCC,MAApC,EAA4CC,UAA5C,EAAwDC,OAAxD,CAAP;AACD,GAFM,CAAP;AAGD","sourcesContent":["import parseCell from './parseCell'\r\n\r\nimport {\r\n getCells,\r\n getMergedCells\r\n} from '../xml/xlsx'\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"}
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = parseDimensions;
7
+
8
+ var _coordinates = require("./coordinates");
9
+
10
+ var _xlsx = require("../xml/xlsx");
11
+
12
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
13
+
14
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
15
+
16
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
17
+
18
+ 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; }
19
+
20
+ function _iterableToArrayLimit(arr, i) { var _i = arr && (typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]); if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
21
+
22
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
23
+
24
+ function parseDimensions(sheet) {
25
+ var dimensions = (0, _xlsx.getDimensions)(sheet);
26
+
27
+ if (dimensions) {
28
+ dimensions = dimensions.split(':').map(_coordinates.parseCellCoordinates).map(function (_ref) {
29
+ var _ref2 = _slicedToArray(_ref, 2),
30
+ row = _ref2[0],
31
+ column = _ref2[1];
32
+
33
+ return {
34
+ row: row,
35
+ column: column
36
+ };
37
+ }); // When there's only a single cell on a sheet
38
+ // there can sometimes be just "A1" for the dimensions string.
39
+
40
+ if (dimensions.length === 1) {
41
+ dimensions = [dimensions[0], dimensions[0]];
42
+ }
43
+
44
+ return dimensions;
45
+ }
46
+ }
47
+ //# sourceMappingURL=parseDimensions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../source/read/parseDimensions.js"],"names":["parseDimensions","sheet","dimensions","split","map","parseCellCoordinates","row","column","length"],"mappings":";;;;;;;AAAA;;AAIA;;;;;;;;;;;;;;AAIe,SAASA,eAAT,CAAyBC,KAAzB,EAAgC;AAC7C,MAAIC,UAAU,GAAG,yBAAcD,KAAd,CAAjB;;AACA,MAAIC,UAAJ,EAAgB;AACdA,IAAAA,UAAU,GAAGA,UAAU,CAACC,KAAX,CAAiB,GAAjB,EAAsBC,GAAtB,CAA0BC,iCAA1B,EAAgDD,GAAhD,CAAoD;AAAA;AAAA,UAAEE,GAAF;AAAA,UAAOC,MAAP;;AAAA,aAAoB;AACnFD,QAAAA,GAAG,EAAHA,GADmF;AAEnFC,QAAAA,MAAM,EAANA;AAFmF,OAApB;AAAA,KAApD,CAAb,CADc,CAKd;AACA;;AACA,QAAIL,UAAU,CAACM,MAAX,KAAsB,CAA1B,EAA6B;AAC3BN,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'\r\n\r\nimport {\r\n getDimensions\r\n} from '../xml/xlsx'\r\n\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 // When there's only a single cell on a sheet\r\n // there can sometimes be just \"A1\" for the dimensions string.\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"}
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = parseFilePaths;
7
+
8
+ var _xlsx = require("../xml/xlsx");
9
+
10
+ /**
11
+ * Returns sheet file paths.
12
+ * Seems that the correct place to look for the `sheetId` -> `filename` mapping
13
+ * is `xl/_rels/workbook.xml.rels` file.
14
+ * https://github.com/tidyverse/readxl/issues/104
15
+ * @param {string} content — `xl/_rels/workbook.xml.rels` file contents.
16
+ * @param {object} xml
17
+ * @return {object}
18
+ */
19
+ function parseFilePaths(content, xml) {
20
+ // Example:
21
+ // <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
22
+ // ...
23
+ // <Relationship
24
+ // Id="rId3"
25
+ // Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet"
26
+ // Target="worksheets/sheet1.xml"/>
27
+ // </Relationships>
28
+ var document = xml.createDocument(content);
29
+ var filePaths = {
30
+ sheets: {},
31
+ sharedStrings: undefined,
32
+ styles: undefined
33
+ };
34
+
35
+ var addFilePathInfo = function addFilePathInfo(relationship) {
36
+ var filePath = relationship.getAttribute('Target');
37
+ var fileType = relationship.getAttribute('Type');
38
+
39
+ switch (fileType) {
40
+ case 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles':
41
+ filePaths.styles = getFilePath(filePath);
42
+ break;
43
+
44
+ case 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings':
45
+ filePaths.sharedStrings = getFilePath(filePath);
46
+ break;
47
+
48
+ case 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet':
49
+ filePaths.sheets[relationship.getAttribute('Id')] = getFilePath(filePath);
50
+ break;
51
+ }
52
+ };
53
+
54
+ (0, _xlsx.getRelationships)(document).forEach(addFilePathInfo); // Seems like "sharedStrings.xml" is not required to exist.
55
+ // For example, when the spreadsheet doesn't contain any strings.
56
+ // https://github.com/catamphetamine/read-excel-file/issues/85
57
+ // if (!filePaths.sharedStrings) {
58
+ // throw new Error('"sharedStrings.xml" file not found in the *.xlsx file')
59
+ // }
60
+
61
+ return filePaths;
62
+ }
63
+
64
+ function getFilePath(path) {
65
+ // Normally, `path` is a relative path inside the ZIP archive,
66
+ // like "worksheets/sheet1.xml", or "sharedStrings.xml", or "styles.xml".
67
+ // There has been one weird case when file path was an absolute path,
68
+ // like "/xl/worksheets/sheet1.xml" (specifically for sheets):
69
+ // https://github.com/catamphetamine/read-excel-file/pull/95
70
+ // Other libraries (like `xlsx`) and software (like Google Docs)
71
+ // seem to support such absolute file paths, so this library does too.
72
+ if (path[0] === '/') {
73
+ return path.slice('/'.length);
74
+ } // // Seems like a path could also be a URL.
75
+ // // http://officeopenxml.com/anatomyofOOXML-xlsx.php
76
+ // if (/^[a-z]+\:\/\//.test(path)) {
77
+ // return path
78
+ // }
79
+
80
+
81
+ return 'xl/' + path;
82
+ }
83
+ //# sourceMappingURL=parseFilePaths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../source/read/parseFilePaths.js"],"names":["parseFilePaths","content","xml","document","createDocument","filePaths","sheets","sharedStrings","undefined","styles","addFilePathInfo","relationship","filePath","getAttribute","fileType","getFilePath","forEach","path","slice","length"],"mappings":";;;;;;;AAAA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,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;;AAgBA,8BAAiBT,QAAjB,EAA2Ba,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'\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"}
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = parseProperties;
7
+
8
+ var _xlsx = require("../xml/xlsx");
9
+
10
+ // I guess `xl/workbook.xml` file should always be present inside the *.xlsx archive.
11
+ function parseProperties(content, xml) {
12
+ var book = xml.createDocument(content);
13
+ var properties = {}; // Read `<workbookPr/>` element to detect whether dates are 1900-based or 1904-based.
14
+ // https://support.microsoft.com/en-gb/help/214330/differences-between-the-1900-and-the-1904-date-system-in-excel
15
+ // http://webapp.docx4java.org/OnlineDemo/ecma376/SpreadsheetML/workbookPr.html
16
+
17
+ var workbookProperties = (0, _xlsx.getWorkbookProperties)(book);
18
+
19
+ if (workbookProperties && workbookProperties.getAttribute('date1904') === '1') {
20
+ properties.epoch1904 = true;
21
+ } // Get sheets info (indexes, names, if they're available).
22
+ // Example:
23
+ // <sheets>
24
+ // <sheet
25
+ // xmlns:ns="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
26
+ // name="Sheet1"
27
+ // sheetId="1"
28
+ // ns:id="rId3"/>
29
+ // </sheets>
30
+ // http://www.datypic.com/sc/ooxml/e-ssml_sheet-1.html
31
+
32
+
33
+ properties.sheets = [];
34
+
35
+ var addSheetInfo = function addSheetInfo(sheet) {
36
+ if (sheet.getAttribute('name')) {
37
+ properties.sheets.push({
38
+ id: sheet.getAttribute('sheetId'),
39
+ name: sheet.getAttribute('name'),
40
+ relationId: sheet.getAttribute('r:id')
41
+ });
42
+ }
43
+ };
44
+
45
+ (0, _xlsx.getSheets)(book).forEach(addSheetInfo);
46
+ return properties;
47
+ }
48
+ //# sourceMappingURL=parseProperties.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../source/read/parseProperties.js"],"names":["parseProperties","content","xml","book","createDocument","properties","workbookProperties","getAttribute","epoch1904","sheets","addSheetInfo","sheet","push","id","name","relationId","forEach"],"mappings":";;;;;;;AAAA;;AAKA;AACe,SAASA,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,GAAG,iCAAsBH,IAAtB,CAA3B;;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;;AAUA,uBAAUJ,IAAV,EAAgBa,OAAhB,CAAwBN,YAAxB;AAEA,SAAOL,UAAP;AACD","sourcesContent":["import {\r\n getWorkbookProperties,\r\n getSheets\r\n} from '../xml/xlsx'\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"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = parseSharedStrings;
7
+
8
+ var _xlsx = require("../xml/xlsx");
9
+
10
+ function parseSharedStrings(content, xml) {
11
+ if (!content) {
12
+ return [];
13
+ }
14
+
15
+ return (0, _xlsx.getSharedStrings)(xml.createDocument(content));
16
+ }
17
+ //# sourceMappingURL=parseSharedStrings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../source/read/parseSharedStrings.js"],"names":["parseSharedStrings","content","xml","createDocument"],"mappings":";;;;;;;AAAA;;AAIe,SAASA,kBAAT,CAA4BC,OAA5B,EAAqCC,GAArC,EAA0C;AACvD,MAAI,CAACD,OAAL,EAAc;AACZ,WAAO,EAAP;AACD;;AACD,SAAO,4BAAiBC,GAAG,CAACC,cAAJ,CAAmBF,OAAnB,CAAjB,CAAP;AACD","sourcesContent":["import {\r\n getSharedStrings\r\n} from '../xml/xlsx'\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"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = parseSheet;
7
+
8
+ var _parseCells = _interopRequireDefault(require("./parseCells"));
9
+
10
+ var _parseDimensions = _interopRequireDefault(require("./parseDimensions"));
11
+
12
+ var _coordinates = require("./coordinates");
13
+
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
15
+
16
+ function parseSheet(content, xml, values, styles, properties, options) {
17
+ var sheet = xml.createDocument(content);
18
+ var cells = (0, _parseCells["default"])(sheet, xml, values, styles, properties, options);
19
+ var dimensions = (0, _parseDimensions["default"])(sheet) || (0, _coordinates.calculateDimensions)(cells);
20
+ return {
21
+ cells: cells,
22
+ dimensions: dimensions
23
+ };
24
+ }
25
+ //# sourceMappingURL=parseSheet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../source/read/parseSheet.js"],"names":["parseSheet","content","xml","values","styles","properties","options","sheet","createDocument","cells","dimensions"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;;;AAEe,SAASA,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,GAAG,4BAAWF,KAAX,EAAkBL,GAAlB,EAAuBC,MAAvB,EAA+BC,MAA/B,EAAuCC,UAAvC,EAAmDC,OAAnD,CAAd;AACA,MAAMI,UAAU,GAAG,iCAAgBH,KAAhB,KAA0B,sCAAoBE,KAApB,CAA7C;AAEA,SAAO;AAAEA,IAAAA,KAAK,EAALA,KAAF;AAASC,IAAAA,UAAU,EAAVA;AAAT,GAAP;AACD","sourcesContent":["import parseCells from './parseCells'\r\nimport parseDimensions from './parseDimensions'\r\n\r\nimport { calculateDimensions } from './coordinates'\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 const dimensions = parseDimensions(sheet) || calculateDimensions(cells)\r\n\r\n return { cells, dimensions }\r\n}"],"file":"parseSheet.js"}
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = parseStyles;
7
+
8
+ var _xlsx = require("../xml/xlsx");
9
+
10
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
11
+
12
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
13
+
14
+ 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; }
15
+
16
+ // http://officeopenxml.com/SSstyles.php
17
+ // Returns an array of cell styles.
18
+ // A cell style index is its ID.
19
+ function parseStyles(content, xml) {
20
+ if (!content) {
21
+ return {};
22
+ } // 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
23
+ // https://www.office-forums.com/threads/cellxfs-cellstylexfs.2163519/
24
+
25
+
26
+ var doc = xml.createDocument(content);
27
+ var baseStyles = (0, _xlsx.getBaseStyles)(doc).map(parseCellStyle);
28
+ var numberFormats = (0, _xlsx.getNumberFormats)(doc).map(parseNumberFormatStyle).reduce(function (formats, format) {
29
+ // Format ID is a numeric index.
30
+ // There're some standard "built-in" formats (in Excel) up to about `100`.
31
+ formats[format.id] = format;
32
+ return formats;
33
+ }, []);
34
+
35
+ var getCellStyle = function getCellStyle(xf) {
36
+ if (xf.hasAttribute('xfId')) {
37
+ return _objectSpread(_objectSpread({}, baseStyles[xf.xfId]), parseCellStyle(xf, numberFormats));
38
+ }
39
+
40
+ return parseCellStyle(xf, numberFormats);
41
+ };
42
+
43
+ return (0, _xlsx.getCellStyles)(doc).map(getCellStyle);
44
+ }
45
+
46
+ function parseNumberFormatStyle(numFmt) {
47
+ return {
48
+ id: numFmt.getAttribute('numFmtId'),
49
+ template: numFmt.getAttribute('formatCode')
50
+ };
51
+ } // http://www.datypic.com/sc/ooxml/e-ssml_xf-2.html
52
+
53
+
54
+ function parseCellStyle(xf, numFmts) {
55
+ var style = {};
56
+
57
+ if (xf.hasAttribute('numFmtId')) {
58
+ var numberFormatId = xf.getAttribute('numFmtId'); // Built-in number formats don't have a `<numFmt/>` element in `styles.xml`.
59
+ // https://hexdocs.pm/xlsxir/number_styles.html
60
+
61
+ if (numFmts[numberFormatId]) {
62
+ style.numberFormat = numFmts[numberFormatId];
63
+ } else {
64
+ style.numberFormat = {
65
+ id: numberFormatId
66
+ };
67
+ }
68
+ }
69
+
70
+ return style;
71
+ }
72
+ //# sourceMappingURL=parseStyles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../source/read/parseStyles.js"],"names":["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;;;;;;;;AAMA;AACA;AACA;AACe,SAASA,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,GAAG,yBAAcF,GAAd,EAChBG,GADgB,CACZC,cADY,CAAnB;AAGA,MAAMC,aAAa,GAAG,4BAAiBL,GAAjB,EACnBG,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,SAAO,yBAAcL,GAAd,EAAmBG,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'\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"}