Bug 57462 - Problem with autofilter when reordering sheets.
Summary: Problem with autofilter when reordering sheets.
Status: NEW
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.11-FINAL
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-01-19 12:33 UTC by Thomas
Modified: 2018-01-16 09:03 UTC (History)
1 user (show)



Attachments
Resulting Excel-File (6.00 KB, application/vnd.ms-excel)
2015-01-19 12:33 UTC, Thomas
Details
workbook with autofilter (63.89 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2018-01-16 09:01 UTC, albfan
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas 2015-01-19 12:33:18 UTC
Created attachment 32379 [details]
Resulting Excel-File

I create a new workbook with
1. "Sheet 1" with autofilter 0,0,0,2
2. "Sheet 2" with autofilter 0,0,0,5
3. "Sheet 3" with no autofilter.
4. Set Order of "Sheet 3" to 0.
5. Saving XLS.
=> "Sheet 1" becomes autofilter of "Sheet 2" 0,0,0,5

Here is the used JAVA-Code:

	HSSFWorkbook wb = new HSSFWorkbook();
	HSSFSheet sheet1 = wb.createSheet("Sheet 1");
	HSSFSheet sheet2 = wb.createSheet("Sheet 2");
	HSSFSheet sheet3 = wb.createSheet("Sheet 3");
	sheet1.setAutoFilter(new CellRangeAddress(0, 0, 0, 2));
	sheet2.setAutoFilter(new CellRangeAddress(0, 0, 0, 5));
	wb.setSheetOrder("Sheet 3", 0);
	wb.setSheetOrder("Sheet 1", 1); // Optional ?
	wb.setSheetOrder("Sheet 2", 2); // Optional ?
	FileOutputStream fos = new FileOutputStream("POI-TEST.XLS");
	wb.write(fos);
	fos.close();

I have attached the resulting XLS.

Thanks in advance for fixing!
Comment 1 Dominik Stadler 2015-02-11 20:13:28 UTC
Seems the autofilter is not adjusted when sheet order changes, this is stored as getSpecificBuiltinRecord() in the Workbook, but not adjusted for setSheetOrder(). I tried to adjust this, but it was non-trivial to get this to work.

Note: removeSheet() is likely also affected, similar adjusting of sheetIndexes is likely necessary there as well.
Comment 2 albfan 2018-01-16 09:01:14 UTC
Created attachment 35681 [details]
workbook with autofilter

just open the file with excel an libreoffice.
Comment 3 albfan 2018-01-16 09:02:24 UTC
Adding an autofilter to a sheet from file 1, and shifting first rows, on excel 2016 autofilter is shown correctly from file 2 but on libreoffice 5 it shows the autofilter on file 3

After save autofilter with libreoffice, both programs show autofilter correctly
Comment 4 albfan 2018-01-16 09:03:08 UTC
Adding an autofilter to a sheet from file 1, and shifting first rows, on excel 2016 autofilter is shown correctly from file 2 but on libreoffice 5 it shows the autofilter on file 3

After save autofilter with libreoffice, both programs show autofilter correctly