Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The numFmt tag in the workbook file is missing the formatCode attribute value #1412

Closed
1 of 5 tasks
lianglanzheng opened this issue Sep 5, 2024 · 0 comments
Closed
1 of 5 tasks
Labels
bug file_error file format generation/writing issue xlsx
Milestone

Comments

@lianglanzheng
Copy link

NPOI Version

2.7.1

File Type

  • XLSX
  • XLS
  • DOCX
  • XLSM
  • OTHER

Upload the Excel File

EmptyFormatCode.xlsx

Reproduce Steps

Just open and save the file with NPOI, sample code written in .NET 6:

using NPOI.XSSF.UserModel;

string path = "EmptyFormatCode.xlsx";

XSSFWorkbook workbook;
using (FileStream file = new(path, FileMode.Open, FileAccess.Read))
{
    workbook = new(file);
    file.Close();
}
using (FileStream file = new(path, FileMode.Truncate, FileAccess.Write))
{
    workbook.Write(file);
    file.Close();
}
workbook.Close();

Issue Description

When the formatCode attribute value of the numFmt tag in /xl/styles.xml in the workbook archive is an empty string "", NPOI will treat it as a null value and generate the following form xml:

<numFmt numFmtId="0"/>

The current version of Excel does not seem to accept a formatCode value of null and prompts the following error:

image
image

@tonyqus tonyqus added this to the NPOI 2.7.2 milestone Sep 22, 2024
@tonyqus tonyqus added file_error file format generation/writing issue xlsx labels Sep 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug file_error file format generation/writing issue xlsx
Projects
None yet
Development

No branches or pull requests

2 participants