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.

  • Version=2.5.5.0
  • Insert a new data column code into an existing excel file as follows
 var file = new FileStream(templatePath, FileMode.Open, FileAccess.Read);
 var workbook = new XSSFWorkbook(file);
 var sheet = workbook.GetSheetAt(0) as XSSFSheet;
  • Error when opening the downloaded Report image
  • wrong styles.xml styles.txt

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
lianglanzhengcommented, Mar 29, 2022

Maybe the empty family lable lead to this problem. I reproduced the problem when duplicate specific .xlsx by NPOI 2.5.5. I found that the problem is related to two XML files in the Excel archive:

  • xl/styles.xml
  • xl/sharedStrings.xml

Reproduce code:

using (FileStream iFile = new FileStream(Path, FileMode.Open, FileAccess.Read))
using (FileStream oFile = new FileStream(Path + ".out.xlsx", FileMode.Create, FileAccess.Write))
{
    XSSFWorkbook workbook = new XSSFWorkbook(iFile);
    workbook.Write(oFile);
    workbook.Close();
}

Original styles.xml file:

<fonts count="9">
    <font>
        <sz val="12" />
        <name val="宋体" />
        <family val="0" />
        <charset val="134" />
    </font>
...

NPOI generated:

<fonts count="9">
    <font>
        <sz val="12"/>
        <name val="宋体"/>
        <family/>
        <charset val="134"/>
    </font>
...

Microsoft Excel reported errors:

已删除的部件: 有 XML 错误的 /xl/styles.xml。 (样式) 加载错误。 行 1,列 0。
已修复的记录: /xl/worksheets/sheet1.xml 部分的 单元格信息
已修复的记录: /xl/worksheets/sheet2.xml 部分的 单元格信息

The error disappeared after I manually removed all <family/> in both xml files.

0reactions
luco5826commented, Jul 5, 2022

When will this fix be released? Isn’t there a plan for NPOI version 2.5.7? Do we have to wait for 2.6.0 for this commit (b3ff43f) to be released?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting error on Style.xml in android
My problem is that i am getting error on styles.xml in my android project.May be due to that my R.java is not generating....
Read more >
How to Fix Issues with Styles.xml (Free Download)
styles.xml errors are related to problems that occur at MiniLyrics runtime. Generally, XML errors are caused by missing or corrupt files.
Read more >
Wrong paragraph style applied to imported XML.
i'm importing some fairly complex xml with a few different repeating elements, and the paragraph styles are all wrong for the first instance...
Read more >
xl/styles.xml part with XML error. (Styles) Load error.
I am colouring in specific cells of the worksheet, but when I try and open the file with excel I get this error...
Read more >
Reading Excel Files-- Styles.xml error
It's possible they have a bad formula, and the style.xml was removed from the file. That Excel file maybe corrupt.Also, there are no...
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