Bug 50029 - XSSFWorkbook created cannot be opened by Excel 2007 SP2
Summary: XSSFWorkbook created cannot be opened by Excel 2007 SP2
Status: RESOLVED INVALID
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 3.6-FINAL
Hardware: PC Windows Vista
: P2 blocker (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-29 23:42 UTC by Abhijit Sarkar
Modified: 2010-09-30 00:21 UTC (History)
1 user (show)



Attachments
Relevant class and JUnit test class (1.18 KB, application/x-zip-compressed)
2010-09-29 23:42 UTC, Abhijit Sarkar
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Abhijit Sarkar 2010-09-29 23:42:18 UTC
Created attachment 26101 [details]
Relevant class and JUnit test class

To start with, I am creating only  a blank file. No worksheets, no data. However, when I attempt to open the file with Excel 2007, I get the following popup:

"Excel found unreadable content in 'abc.xlsx'. Do you want to recover the contents of this workbook? If you trust the source of this workbook, click Yes."

After clicking Yes, another popup:
"The workbook cannot be opened or repaired by Microsoft Excel because it is corrupt."

I have attached the relevant class and a JUnit 4 test class.

I am using Vista Business Ed SP2, 64 bit with Office 2007 SP2.
Comment 1 Yegor Kozlov 2010-09-30 00:21:39 UTC
Your code just saves an empty workbook which is invalid:

	wb = new XSSFWorkbook();	
	wb.write(fileOut);

You need to insert at least one sheet to make the workbook readable by Excel, e.g. the following code will produce a valid output:

	wb = new XSSFWorkbook();	
        XSSHSheet sh = wb.createSheet();
	wb.write(fileOut);

Yegor