Issue: style.xml has [Object object] as formatCode #2698
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Somehow the excel file is in a state where exceljs does not handle extracting the numFmt of a DXF conditional format properly and instead has it set to an object.
This results in the generate style.xml file to have a formatCode of
[Object object]
inside which corrupts the file.This fix is to check if the numFmt is of the appropriate string type and if not, corrects it by extracting the formatCode before moving forward on the prepare step of writing.
Test plan
This is the test Excel file I used which has a conditional format on A1:C1 which conditional changes the fill color to yellow and the format to be a custom number format if A1 equals "NO".
CF1.xlsx
I setup a simple
main.js
to read in the test Excel file and write a new filetemp.xlsx
.With current master branch the result of opening the generated file is this:
After repair conditional formatting is removed.
Screenshot of xl/style.xml file with the error:
After the fix the file is generated properly and conditional formatting works as expected.
Screenshot of xl/style.xml with fixed format code:
Related to source code (for typings update)
I'm not really sure what is supposed to go here.