Bug 50315 - XSSF sheet.setAutoFilter() crashes Excel by sorting.
Summary: XSSF sheet.setAutoFilter() crashes Excel by sorting.
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 3.7-FINAL
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
: 50314 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-11-22 11:13 UTC by Jack
Modified: 2013-09-05 15:40 UTC (History)
1 user (show)



Attachments
two .xlsx files, one's autofilter created by POI, the other one's created manually. (8.15 KB, application/x-zip-compressed)
2010-11-22 11:13 UTC, Jack
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jack 2010-11-22 11:13:33 UTC
Created attachment 26330 [details]
two .xlsx files, one's autofilter created by POI, the other one's created manually.

Steps to Reproduce: 
After using the following code to generate a XLSX file, if you open that generated file (I attached here as "AutofilterGeneratedWithPOI.xlsx" in the zip file) and click autofilter to sort any of the columns, MS Excel would crash. However, if you delete the autofilter and using Excel to add it back again (I attached here as "AutofilterGeneratedWithinExcel.xlsx"), everything would work just fine. I recreated this scenario on two boxes and two separated projects.

Actual Results: 
Excel Application Crashes.

Build Date & Platform: 
Windows XP, NetBean, Excel 2007, 10/28/2011

Additional Builds and Platforms:
Windows XP, RAD 7.5 11/15/2011, samething happens.

#####################################################################

import java.io.FileOutputStream;

import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;


public class RptJobController {

	public static void main(String args[]) 
	{	
		FileOutputStream fileOut = null;
		try {
			XSSFWorkbook wb = new XSSFWorkbook();
			fileOut = new FileOutputStream("c:\\workbook.xlsx");
			XSSFSheet sheet = wb.createSheet("new sheet");
			// Create a row and put some cells in it.
			XSSFRow row = sheet.createRow((short) 0);
			// Create a cell and put a value in it.
			row.createCell(0).setCellValue("irrelevant");
			row.createCell(1).setCellValue("Number");
			row.createCell(2).setCellValue("String");

			row = sheet.createRow((short) 1);
			row.createCell(1).setCellValue(1);
			row.createCell(2).setCellValue("This is a string");

			row = sheet.createRow((short) 2);
			row.createCell(1).setCellValue(2);
			row.createCell(2).setCellValue("This is a string");

			row = sheet.createRow((short) 3);
			row.createCell(1).setCellValue(3);
			row.createCell(2).setCellValue("This is a string");

			sheet.setAutoFilter(CellRangeAddress.valueOf("B1:C1"));
			sheet.autoSizeColumn((short) 2);
			wb.write(fileOut);
			fileOut.close();
		} catch (Exception ex) {

		}	
	}
}
Comment 1 Jack 2010-11-22 11:21:26 UTC
*** Bug 50314 has been marked as a duplicate of this bug. ***
Comment 2 Yegor Kozlov 2010-12-02 10:28:47 UTC
Fixed in r1041407

It turned out that autofilters must be registered in workbook.xml. Without registering Excel recognizes the autofilter but crashes when you try to use it.

Yegor