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!
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.
Created attachment 35681 [details] workbook with autofilter just open the file with excel an libreoffice.
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