Bug 54591 - Excel: unreadable content error when opening POI generated xls in Excel on Windows 7
Summary: Excel: unreadable content error when opening POI generated xls in Excel on Wi...
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.9-FINAL
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2013-02-20 18:02 UTC by Eric Pias
Modified: 2013-05-30 18:06 UTC (History)
1 user (show)

Use this class to generate files that will not open in Excel under Windows 7 (971 bytes, application/octet-stream)
2013-02-20 18:02 UTC, Eric Pias
Excel workbook that opens successfully. (4.00 KB, application/vnd.ms-excel)
2013-02-22 11:45 UTC, Mark B

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Pias 2013-02-20 18:02:34 UTC
Created attachment 29972 [details]
Use this class to generate files that will not open in Excel under Windows 7

I have attached a very simple example class that produces the most simple xls file possible that illustrates this problem.  The problem is that when I try to use Excel on Windows 7 to open the file generated using POI, Excel will not open it and shows an error (unreadable content error).  The same file can be opened in Excel 2008 for Mac.

The following MS article explains an issue that may be the issue here:

To replicate, compile the attached java class with poi 3.9.  Run it to produce the xls.  Then under windows 7, try to open the file in Excel.  You should see the error.  I also observe the issue back poi 3.0.1.
Comment 1 Mark B 2013-02-22 11:45:22 UTC
Created attachment 29980 [details]
Excel workbook that opens successfully.
Comment 2 Mark B 2013-02-22 11:59:07 UTC
Hm, looks like I was able to upload the attachment but my comments were lost.

Anyway, I was unable to re-create the problem. Currently, I am running under Windows 7, 64 bit Home Premium and the class I wrote was compiled and run against version 1.6.0_33 of Sun's (Oracle's) Java implementation and version 3.9 of POI. I did not use the exact code you posted - forgot to save the code to my PC - but wrote my own class to perform the test:

import java.io.*;
import org.apache.poi.hssf.usermodel.*;

 * @author Mark Beardsley
public class OpenError {
    public OpenError(String filename) throws IOException {
        HSSFWorkbook workbook = null;
        HSSFSheet sheet = null;
        FileOutputStream fos = null;
        try {
            workbook = new HSSFWorkbook();
            sheet = workbook.createSheet("In Error.");
            fos = new FileOutputStream(filename);
        finally {
            if(fos != null) {

The only difference between the two being that I did not flush the output stream but I cannot imagine that will make a profound difference. Some time ago, I do remember problems with building the api with version 1.7 of Java but know that Yegor planned to address this and am fairly certain that he has.

Could you try to open the attached Excel workbook using your version of Excel and see what happens please? It may well be that it is the version of Excel you are using which is important rather than the operating system.
Comment 3 Dominik Stadler 2013-05-30 16:16:17 UTC
needinfo based on previous comment
Comment 4 Eric Pias 2013-05-30 18:06:19 UTC
This issue was definitely seen in our testing.  Unfortunately, we are currently unable to replicate this issue anymore after much trying.  There are a number of different factors involved that make it difficult.  I hate to see anyone burning cycles on this, so I will attempt to close/resolve it.