question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

File populated by xlsx-populate can not open with Excel

See original GitHub issue

I have a template xlsm file and I use this library to populate some data. However, my template file cannot open with Excel after xlsx-populate edited. Excel prompts: image After clicking “Yes”, all cell format are lost, and Excel prompts “Removed Part: /xl/styles.xml part with XML error. (Styles) Load error. Line 1, column 0.” According to my resarch, this is due to wrong handing for paticular cell style by xlsx-populate. When setting a cell style to horizontal center, xlsx-populate will append <alignment horizontal="center"/> after original cell style <protection locked="0"/>, look like this:

<xf numFmtId="0" fontId="8" fillId="5" borderId="1" xfId="0" applyFill="1" applyProtection="1" applyFont="1" applyBorder="1">
	<protection locked="0"/>
	<alignment horizontal="center"/>
</xf>

But unfortunately, it seems Excel expects all cell format property are located before <protection locked="0"/>. If switch their positions like this:

<xf numFmtId="0" fontId="8" fillId="5" borderId="1" xfId="0" applyFill="1" applyProtection="1" applyFont="1" applyBorder="1">
	<alignment horizontal="center"/>
	<protection locked="0"/>
</xf>

Excel can open this file normally then.

Thank you for your contribution, your work has helped me a lot, also hope that this library can be made better.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:1
  • Comments:14 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mdgozzacommented, Jun 19, 2019

-> Bump here <- I ran into this issue as well, I will attempt to debug and maybe suggest a change myself tomorrow, however I’ve only just started working with xlsx-populate ( my favorite open source repo 😉)

1reaction
garrensweetcommented, Mar 7, 2019

Actually, I’ve found it was a combination of issues. I managed to work around this one but found another issue. It only impacts excel and not open office.

Read more comments on GitHub >

github_iconTop Results From Across the Web

xlsx-populate - npm
Right-click on a cell in Excel with the number format you want. Click on "Format Cells..." Switch the category to "Custom" if it...
Read more >
Error message when you open or save a file in Microsoft Excel
When you open or save a file in Microsoft Excel, you may receive one of the following error messages: Error message 1. Filename...
Read more >
Hot to skip hidden rows while parsing an excel file with xlsx ...
Is there a way to do this? This code reading all rows: const values = workbook.sheet("Sheet20").range( ...
Read more >
XLSX-populate: Read/write Excel XLSX - Morioh
To populate data in a workbook, you first load one (either blank, from data, or from file). Then you can access sheets and...
Read more >
JavaScript Library to Generate and Parse Excel XLSX Files
xlsx-populate - Open Source JavaScript API to Populate Excel data from a sheet, ... xlsx-populate is a powerful JavaScript library that enables software ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found