Bug 60651 - Auto filter crashes excel when sorting
Summary: Auto filter crashes excel when sorting
Status: RESOLVED INVALID
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.15-FINAL
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-01-26 16:59 UTC by Ardel Grider
Modified: 2020-03-08 09:32 UTC (History)
2 users (show)



Attachments
This is the file that crashes. (18.50 KB, application/vnd.ms-excel)
2017-01-26 16:59 UTC, Ardel Grider
Details
This is the file where I removed and added the auto filter (25.50 KB, application/vnd.ms-excel)
2017-01-26 17:00 UTC, Ardel Grider
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ardel Grider 2017-01-26 16:59:17 UTC
Created attachment 34681 [details]
This is the file that crashes.

I am having a crashing issue with excel after I add a auto filter thru java. After adding the filter to excel columns if I open the excel sheet and attempt to sort, using the drop down arrow on the column header, it crashes every time. If I first filter, like unchecking the blanks option from the drop down, then I can sort and use the sheet like normal with no crashes. If I try to sort using the Sort & Filter button in the editing section at the top of excel it will sort just fine but remove the auto filter. Also if I remove and re-add the filter it doesn't crash and works as expected. Is there a way to make it to where we can add the auto filter thru java then be able to sort before making any other changes to the sheet? I have pasted my code below and I have attached both the excel sheet that is create thru java and pre and post fixing it.


FileInputStream fileIn = new FileInputStream("C:\\Users\\gria\\Desktop\\Fleet Manager Summary.xls");
			HSSFWorkbook report = new HSSFWorkbook(fileIn);
			
			Sheet sheet = report.getSheetAt(0);
			sheet.setAutoFilter(CellRangeAddress.valueOf("A5:O5"));
	
			FileOutputStream fileOut = new FileOutputStream("C:\\Users\\gria\\Desktop\\Fleet Manager SummaryT.xls");
			report.write(fileOut);
			report.close();
			fileOut.close();
			fileIn.close();
Comment 1 Ardel Grider 2017-01-26 17:00:10 UTC
Created attachment 34682 [details]
This is the file where I removed and added the auto filter
Comment 2 Nick Burch 2017-01-26 17:02:28 UTC
If POI is generating a file that Excel gives warnings or errors about, that's something to report here first

If POI is generating a file that makes Excel crash, then that's something you need to report to Microsoft! They generally are quite keen to make fixes that avoids their software crashing, especially as some crashes may turn out to have security implications above and beyond the DoS effects of the crash.

We can certainly take a look at the issue on the POI side, especially if we can find out what specific bit Excel dislikes, but talking to Microsoft needs to be your top priority here!
Comment 3 Ardel Grider 2017-01-26 18:42:44 UTC
Thank you for the quick reply. I have went to Microsoft's community page and posted about the crash as of now. Link: https://answers.microsoft.com/en-us/msoffice/forum/msoffice_excel-mso_other/why-is-this-excel-file-created-from-my-java-code/358e5a35-db8d-46cc-96ed-b9252a29c526?tm=1485456007886
Comment 4 Dominik Stadler 2020-03-08 09:32:20 UTC
We cannot prevent Excel from crashing here and it is hard to find out what exactly triggers the crash.

As far as we see Apache POI is writing the format correctly here, also LibreOffice correctly opens and sorts this document.

If this is still an issue you likely need to use more official Microsoft support channels where you receive more responses.

Overall I don't see anything that can be done in Apache POI right now.