xlsx-template-browser 0.2.0 → 0.2.1

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 (2) hide show
  1. package/lib/main.js +6 -1
  2. package/package.json +1 -1
package/lib/main.js CHANGED
@@ -41,6 +41,7 @@ const replace = async (template, data) => {
41
41
  // Create date number format
42
42
  const styleSheet = domStyle.querySelector('styleSheet')
43
43
  let numFmts = domStyle.querySelector('numFmts')
44
+ let stylesAreSet = Boolean(numFmts)
44
45
  if (!numFmts) numFmts = document.createElementNS(null, 'numFmts')
45
46
  let numFmt = document.createElementNS(null, 'numFmt')
46
47
  numFmt.setAttributeNS(null, 'numFmtId', '166')
@@ -55,7 +56,11 @@ const replace = async (template, data) => {
55
56
  newNumFmts.append(numFmt)
56
57
  count++
57
58
  newNumFmts.setAttribute('count', count)
58
- styleSheet.prepend(newNumFmts)
59
+ if (stylesAreSet) {
60
+ numFmts.replaceWith(newNumFmts)
61
+ } else {
62
+ styleSheet.prepend(newNumFmts)
63
+ }
59
64
 
60
65
  // Add a style for the date format
61
66
  const cellXfs = domStyle.querySelector('cellXfs')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xlsx-template-browser",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "On-the-fly generation of .xlsx (Excel) files directly within the browser using templates constructed in Excel.",
5
5
  "main": "./lib/index",
6
6
  "files": [