exceljs: [BUG] Template data validation lost
🐛 Bug Report
I have a template Excel file which includes data validations. When I use exceljs to write data to the template the data validations are lost.
Lib version: 3.8.2
Steps To Reproduce
// index.js
const Excel = require("exceljs");
(async () => {
const workbook = new Excel.Workbook();
await workbook.xlsx.readFile("./template.xlsx"); // Has data validation
await workbook.xlsx.writeFile("./output.xlsx"); // Data validation lost
})();
See attached sample project: exceljs-bug.zip
The expected behaviour:
Data validation is retained.
About this issue
- Original URL
- State: open
- Created 4 years ago
- Comments: 20 (7 by maintainers)
So todo list:
Worksheet.dataValidationshttps://github.com/exceljs/exceljs/blob/master/index.d.ts#L955dataValidationgetter and setter forColumndataValidationgetter and setter forRowRangeAny updates on this issue or the #1752 PR?
Hi,
Any news about this issue?
@mpalavrov thank you, your example is pretty good because it shows that what I really don’t understand yet.
Does anyone have any idea why some data validations is under worksheet (
worksheet>dataValidations) and some are insideworksheet>extLst>ext>x14:dataValidations?by following this: [MS-XLSX]-120411.pdf they should be written into
worksheet>extLst>ext>x14:dataValidationsbut as we see in Your example, it’s not always true.so, our library handles one of two ways for data validations, I need to make more research for now…
@Alanscut @cduff thank you for that precise information, I’ll attempt to fix it.
@cduff btw. I create a library for generating xlsx from templates: https://github.com/Siemienik/xlsx-renderer It’s based on exceljs, so this bug will occur there too, but I think It should be quite useful for you 😃
@cduff Inconsistent xml structure in Sheet1.xml will cause data validation to be lost. See data-validations-xform.js.
@Siemienik @guyonroche There is more than one such error, See Issue #918.
template.xlsx
File generated by workbook.xlsx.writeFile()
Is there any development on this ? I tested it today (4.1.1) and it’s not working properly.
@Siemienik would love to help you out on this issue, I have a project that requires persistence of data validations !
@Siemienik, I Would like to tell you that I don’t have this issue with the latest version of the exceljs. You can test it yourself if you want, but for me, it is solved.
As I found here: [MS-XLSX]-120411.pdf, our library read and parse data validations in 100% wrong, I’m still working on this issue.