Excel file is always modified even if only opened for reading
rh101 opened this issue · comments
RH 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.
Tony Qu commented
You can try WorkbookFactory.Create(inputstream, readonly) method
npoi/ooxml/SS/UserModel/WorkbookFactory.cs
Line 124 in 4eb5d0e