Description
🐛 Bug Report
When trying to serialize a simple list of strings to XLSX using stream.xlsx.WorkbookWriter
i get unreadable XLSX file - MS Excel complains that the file is broken. Looking inside the XML-files - it's broken for sure. Here's an example:
Lib version: 1.15.0
Steps To Reproduce
Run this sample code to output test.xslx
file.
const ExcelJS = require('exceljs')
const filename = './test.xlsx'
const testThat = async () => {
const workbook = new ExcelJS.stream.xlsx.WorkbookWriter({ filename, useStyles: true, useSharedStrings: true })
const worksheet = workbook.addWorksheet('Data', {})
const row = worksheet.addRow()
row.values = ['hasOwnProperty', 'prototype', 'constructor']
row.commit()
return await workbook.commit()
}
testThat().then(result => console.log(result.modified))
Unzip xl/sharedStrings.xml
and xl/worksheets/sheet1.xml
files from the resulting test.xslx
and pretty-print them using xmllint
:
7z e test.xlsx xl/worksheets/sheet1.xml xl/sharedStrings.xml
xmllint --pretty 1 sharedStrings.xml
xmllint --pretty 1 sheet1.xml
The expected behaviour:
All 3 strings hasOwnProperty
, prototype
, constructor
should have been added to sharedStrings.xml
and referenced from the sheet1.xml
file by index.
Here's what i see in the sheet1.xml
now - only the prototype
string has been mapped correctly, and two other strings have been replaced with the weird function ... { [native code] }
which breaks MS Excel.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac" mc:Ignorable="x14ac">
<sheetFormatPr defaultRowHeight="15" outlineLevelRow="0" outlineLevelCol="0" x14ac:dyDescent="55"/>
<sheetData>
<row r="1" spans="1:3" x14ac:dyDescent="0.25">
<c r="A1" t="s">
<v>function hasOwnProperty() { [native code] }</v>
</c>
<c r="B1" t="s">
<v>0</v>
</c>
<c r="C1" t="s">
<v>function Object() { [native code] }</v>
</c>
</row>
</sheetData>
<pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3"/>
<pageSetup orientation="portrait" horizontalDpi="4294967295" verticalDpi="4294967295" scale="100" fitToWidth="1" fitToHeight="1"/>
</worksheet>