nissl-lab / npoi

a .NET library that can read/write Office formats without Microsoft Office installed. No COM+, no interop.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Excel file is always modified even if only opened for reading

rh101 opened this issue · comments

commented

NPOI Version

2.7.0

File Type

  • XLSX
  • XLS
  • DOCX
  • XLSM
  • OTHER

Upload the Excel File

Original file:
Test_original.xlsx

Resulting file after calling new XSSFWorkbook("Test_original.xlsx") and then closing the file:
Test_modified.xlsx

Reproduce Steps

using var workbook = new XSSFWorkbook("Test_original.xlsx");
// Close and dispose workbook
// Input file is modified when it should not be

Issue Description

Opening a file, reading information from it, then closing it, should not be modifying the original input file. At no point was the Excel file modified in code. It can be reproduced by opening the file then closing it using the above snippet of code.

You can try WorkbookFactory.Create(inputstream, readonly) method

public static IWorkbook Create(Stream inputStream, bool bReadonly)