read-excel-file 5.2.7 → 5.2.11

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 (91) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/README.md +4 -0
  3. package/bundle/read-excel-file.min.js +2 -2
  4. package/bundle/read-excel-file.min.js.map +1 -1
  5. package/commonjs/read/coordinates.js +56 -0
  6. package/commonjs/read/coordinates.js.map +1 -0
  7. package/commonjs/read/dropEmptyColumns.js +52 -0
  8. package/commonjs/read/dropEmptyColumns.js.map +1 -0
  9. package/commonjs/read/dropEmptyColumns.test.js.map +1 -0
  10. package/commonjs/read/dropEmptyRows.js +55 -0
  11. package/commonjs/read/dropEmptyRows.js.map +1 -0
  12. package/commonjs/read/dropEmptyRows.test.js.map +1 -0
  13. package/commonjs/read/getData.js +99 -0
  14. package/commonjs/read/getData.js.map +1 -0
  15. package/commonjs/read/parseCell.js +71 -0
  16. package/commonjs/read/parseCell.js.map +1 -0
  17. package/commonjs/read/parseCellValue.js +204 -0
  18. package/commonjs/read/parseCellValue.js.map +1 -0
  19. package/commonjs/read/parseCells.js +30 -0
  20. package/commonjs/read/parseCells.js.map +1 -0
  21. package/commonjs/read/parseDimensions.js +47 -0
  22. package/commonjs/read/parseDimensions.js.map +1 -0
  23. package/commonjs/read/parseFilePaths.js +83 -0
  24. package/commonjs/read/parseFilePaths.js.map +1 -0
  25. package/commonjs/read/parseProperties.js +48 -0
  26. package/commonjs/read/parseProperties.js.map +1 -0
  27. package/commonjs/read/parseSharedStrings.js +17 -0
  28. package/commonjs/read/parseSharedStrings.js.map +1 -0
  29. package/commonjs/read/parseSheet.js +25 -0
  30. package/commonjs/read/parseSheet.js.map +1 -0
  31. package/commonjs/read/parseStyles.js +72 -0
  32. package/commonjs/read/parseStyles.js.map +1 -0
  33. package/commonjs/read/readXlsx.js +25 -657
  34. package/commonjs/read/readXlsx.js.map +1 -1
  35. package/commonjs/types/URL.js +56 -2
  36. package/commonjs/types/URL.js.map +1 -1
  37. package/commonjs/xml/dom.js +17 -3
  38. package/commonjs/xml/dom.js.map +1 -1
  39. package/commonjs/xml/xlsx-xpath.js +10 -0
  40. package/commonjs/xml/xlsx-xpath.js.map +1 -1
  41. package/commonjs/xml/xlsx.js +22 -0
  42. package/commonjs/xml/xlsx.js.map +1 -1
  43. package/commonjs/xml/xmlNode.js +1 -1
  44. package/commonjs/xml/xmlNode.js.map +1 -1
  45. package/{index.d.ts.test → index.d.ts} +1 -4
  46. package/modules/read/coordinates.js +48 -0
  47. package/modules/read/coordinates.js.map +1 -0
  48. package/modules/read/dropEmptyColumns.js +45 -0
  49. package/modules/read/dropEmptyColumns.js.map +1 -0
  50. package/modules/read/dropEmptyColumns.test.js.map +1 -0
  51. package/modules/read/dropEmptyRows.js +48 -0
  52. package/modules/read/dropEmptyRows.js.map +1 -0
  53. package/modules/read/dropEmptyRows.test.js.map +1 -0
  54. package/modules/read/getData.js +88 -0
  55. package/modules/read/getData.js.map +1 -0
  56. package/modules/read/parseCell.js +59 -0
  57. package/modules/read/parseCell.js.map +1 -0
  58. package/modules/read/parseCellValue.js +192 -0
  59. package/modules/read/parseCellValue.js.map +1 -0
  60. package/modules/read/parseCells.js +19 -0
  61. package/modules/read/parseCells.js.map +1 -0
  62. package/modules/read/parseDimensions.js +38 -0
  63. package/modules/read/parseDimensions.js.map +1 -0
  64. package/modules/read/parseFilePaths.js +76 -0
  65. package/modules/read/parseFilePaths.js.map +1 -0
  66. package/modules/read/parseProperties.js +40 -0
  67. package/modules/read/parseProperties.js.map +1 -0
  68. package/modules/read/parseSharedStrings.js +9 -0
  69. package/modules/read/parseSharedStrings.js.map +1 -0
  70. package/modules/read/parseSheet.js +13 -0
  71. package/modules/read/parseSheet.js.map +1 -0
  72. package/modules/read/parseStyles.js +64 -0
  73. package/modules/read/parseStyles.js.map +1 -0
  74. package/modules/read/readXlsx.js +20 -653
  75. package/modules/read/readXlsx.js.map +1 -1
  76. package/modules/types/URL.js +56 -2
  77. package/modules/types/URL.js.map +1 -1
  78. package/modules/xml/dom.js +14 -3
  79. package/modules/xml/dom.js.map +1 -1
  80. package/modules/xml/xlsx-xpath.js +6 -0
  81. package/modules/xml/xlsx-xpath.js.map +1 -1
  82. package/modules/xml/xlsx.js +19 -1
  83. package/modules/xml/xlsx.js.map +1 -1
  84. package/modules/xml/xmlNode.js +1 -1
  85. package/modules/xml/xmlNode.js.map +1 -1
  86. package/node/{index.d.ts.test → index.d.ts} +1 -1
  87. package/package.json +6 -5
  88. package/schema/{index.d.ts.test → index.d.ts} +0 -0
  89. package/types.d.ts +1 -4
  90. package/commonjs/read/readXlsx.test.js.map +0 -1
  91. package/modules/read/readXlsx.test.js.map +0 -1
@@ -0,0 +1,40 @@
1
+ import { getWorkbookProperties, getSheets } from '../xml/xlsx'; // I guess `xl/workbook.xml` file should always be present inside the *.xlsx archive.
2
+
3
+ export default function parseProperties(content, xml) {
4
+ var book = xml.createDocument(content);
5
+ var properties = {}; // Read `<workbookPr/>` element to detect whether dates are 1900-based or 1904-based.
6
+ // https://support.microsoft.com/en-gb/help/214330/differences-between-the-1900-and-the-1904-date-system-in-excel
7
+ // http://webapp.docx4java.org/OnlineDemo/ecma376/SpreadsheetML/workbookPr.html
8
+
9
+ var workbookProperties = getWorkbookProperties(book);
10
+
11
+ if (workbookProperties && workbookProperties.getAttribute('date1904') === '1') {
12
+ properties.epoch1904 = true;
13
+ } // Get sheets info (indexes, names, if they're available).
14
+ // Example:
15
+ // <sheets>
16
+ // <sheet
17
+ // xmlns:ns="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
18
+ // name="Sheet1"
19
+ // sheetId="1"
20
+ // ns:id="rId3"/>
21
+ // </sheets>
22
+ // http://www.datypic.com/sc/ooxml/e-ssml_sheet-1.html
23
+
24
+
25
+ properties.sheets = [];
26
+
27
+ var addSheetInfo = function addSheetInfo(sheet) {
28
+ if (sheet.getAttribute('name')) {
29
+ properties.sheets.push({
30
+ id: sheet.getAttribute('sheetId'),
31
+ name: sheet.getAttribute('name'),
32
+ relationId: sheet.getAttribute('r:id')
33
+ });
34
+ }
35
+ };
36
+
37
+ getSheets(book).forEach(addSheetInfo);
38
+ return properties;
39
+ }
40
+ //# sourceMappingURL=parseProperties.js.map
@@ -0,0 +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,aAHP,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'\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,9 @@
1
+ import { getSharedStrings } from '../xml/xlsx';
2
+ export default function parseSharedStrings(content, xml) {
3
+ if (!content) {
4
+ return [];
5
+ }
6
+
7
+ return getSharedStrings(xml.createDocument(content));
8
+ }
9
+ //# sourceMappingURL=parseSharedStrings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../source/read/parseSharedStrings.js"],"names":["getSharedStrings","parseSharedStrings","content","xml","createDocument"],"mappings":"AAAA,SACEA,gBADF,QAEO,aAFP;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'\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,13 @@
1
+ import parseCells from './parseCells';
2
+ import parseDimensions from './parseDimensions';
3
+ import { calculateDimensions } from './coordinates';
4
+ export default function parseSheet(content, xml, values, styles, properties, options) {
5
+ var sheet = xml.createDocument(content);
6
+ var cells = parseCells(sheet, xml, values, styles, properties, options);
7
+ var dimensions = parseDimensions(sheet) || calculateDimensions(cells);
8
+ return {
9
+ cells: cells,
10
+ dimensions: dimensions
11
+ };
12
+ }
13
+ //# sourceMappingURL=parseSheet.js.map
@@ -0,0 +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,cAAvB;AACA,OAAOC,eAAP,MAA4B,mBAA5B;AAEA,SAASC,mBAAT,QAAoC,eAApC;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;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'\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,64 @@
1
+ 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; }
2
+
3
+ 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; }
4
+
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
+
7
+ import { getBaseStyles, getCellStyles, getNumberFormats } from '../xml/xlsx'; // http://officeopenxml.com/SSstyles.php
8
+ // Returns an array of cell styles.
9
+ // A cell style index is its ID.
10
+
11
+ export default function parseStyles(content, xml) {
12
+ if (!content) {
13
+ return {};
14
+ } // 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
15
+ // https://www.office-forums.com/threads/cellxfs-cellstylexfs.2163519/
16
+
17
+
18
+ var doc = xml.createDocument(content);
19
+ var baseStyles = getBaseStyles(doc).map(parseCellStyle);
20
+ var numberFormats = getNumberFormats(doc).map(parseNumberFormatStyle).reduce(function (formats, format) {
21
+ // Format ID is a numeric index.
22
+ // There're some standard "built-in" formats (in Excel) up to about `100`.
23
+ formats[format.id] = format;
24
+ return formats;
25
+ }, []);
26
+
27
+ var getCellStyle = function getCellStyle(xf) {
28
+ if (xf.hasAttribute('xfId')) {
29
+ return _objectSpread(_objectSpread({}, baseStyles[xf.xfId]), parseCellStyle(xf, numberFormats));
30
+ }
31
+
32
+ return parseCellStyle(xf, numberFormats);
33
+ };
34
+
35
+ return getCellStyles(doc).map(getCellStyle);
36
+ }
37
+
38
+ function parseNumberFormatStyle(numFmt) {
39
+ return {
40
+ id: numFmt.getAttribute('numFmtId'),
41
+ template: numFmt.getAttribute('formatCode')
42
+ };
43
+ } // http://www.datypic.com/sc/ooxml/e-ssml_xf-2.html
44
+
45
+
46
+ function parseCellStyle(xf, numFmts) {
47
+ var style = {};
48
+
49
+ if (xf.hasAttribute('numFmtId')) {
50
+ var numberFormatId = xf.getAttribute('numFmtId'); // Built-in number formats don't have a `<numFmt/>` element in `styles.xml`.
51
+ // https://hexdocs.pm/xlsxir/number_styles.html
52
+
53
+ if (numFmts[numberFormatId]) {
54
+ style.numberFormat = numFmts[numberFormatId];
55
+ } else {
56
+ style.numberFormat = {
57
+ id: numberFormatId
58
+ };
59
+ }
60
+ }
61
+
62
+ return style;
63
+ }
64
+ //# sourceMappingURL=parseStyles.js.map
@@ -0,0 +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,aAJP,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'\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"}