Steps to reproduce:
1. Create an Excel (xlsx/xlsm) file with a filter. Filter some values and save the file.
2. Try to write and modify some of the lines in the filtered data (slected/unselected), using the NPOI library
3. Open the Excel file in MS Office Excel.
Expected behaviour:
The Excel file should open properly.
Actual behaviour:
Cannot open the file and getting the error message:
Microsoft Excel
Excel founf unreadable content in '<FILE-NAME>.xlsx'. Do you want to recover the contents of this workbook? If you trust the source of this workbook, click Yes.
Clicking Yes gives the error message:
Microsoft Excel
Excel cannot open the file '<FILE-NAME>.xlsx'. because the file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file.
```
var fileInfo = new FileInfo("SheetNameContainsFilteredCells.xlsx");
IWorkbook workbook;
using (var fileStream = fileInfo.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
workbook = WorkbookFactory.Create(fileStream);
}
using (var stream = fileInfo.OpenWrite())
{
workbook.Write(stream);
}
```
1. Create an Excel (xlsx/xlsm) file with a filter. Filter some values and save the file.
2. Try to write and modify some of the lines in the filtered data (slected/unselected), using the NPOI library
3. Open the Excel file in MS Office Excel.
Expected behaviour:
The Excel file should open properly.
Actual behaviour:
Cannot open the file and getting the error message:
Microsoft Excel
Excel founf unreadable content in '<FILE-NAME>.xlsx'. Do you want to recover the contents of this workbook? If you trust the source of this workbook, click Yes.
Clicking Yes gives the error message:
Microsoft Excel
Excel cannot open the file '<FILE-NAME>.xlsx'. because the file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file.
```
var fileInfo = new FileInfo("SheetNameContainsFilteredCells.xlsx");
IWorkbook workbook;
using (var fileStream = fileInfo.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
workbook = WorkbookFactory.Create(fileStream);
}
using (var stream = fileInfo.OpenWrite())
{
workbook.Write(stream);
}
```