dotnetcore / NPOI

A .NET library for reading and writing Microsoft Office binary and OOXML file formats.
Apache License 2.0
1.93k stars 413 forks source link

Cannot update file - error in a saved excel file #184

Open ghost opened 4 years ago

ghost commented 4 years ago

Create empty the Microsoft xlsx file "tmp.xlsx". Use the code below:

XSSFWorkbook xssWorkbook = null;

using (var stream = new FileStream(@"C:\temp\tmp.xlsx", FileMode.Open, FileAccess.Read))
{
    xssWorkbook = new XSSFWorkbook(stream);
}

using (var stream = new FileStream(@"C:\temp\tmp2.xlsx", FileMode.Create, FileAccess.Write))
{
    xssWorkbook.Write(stream);
}

Open the "tmp2.xlsx" file - you will see the below error:

-

Removed records: /xl/workbook.xml