Free Support Forum - aspose.com

Exception when trying to read any Excel 2007 file with Aspose Cells Java 1.9.1

I am using Aspose Cells for Java 1.9.1 to open and read Excel 2007 files.

For any Excel 2007 file I try to open, I receive the following exception:
java.io.Exception, exception message: java.io.IOException: It is not a valid excel2007 file.null

This is an excerpt of the code used to open the file:
try
{
Workbook workbook = new Workbook();
workbook.open(excel2007File.getAbsolutePath(), FileFormatType.EXCEL2007);
Worksheets worksheets = workbook.getWorksheets();
}
catch (IOException e)
{
System.out.println(e);
}

What am I doing wrong?

Lothar

Hi Lothar,

I have tested your code, it works fine. Would you please post your excel file here? For current version of Aspose.Cells for java, some features are not supported for excel 2007, such as chart, image, pivot table, etc.

Here is a sample program:
public static void main(String[] args)
{
try
{
Workbook workbook = new Workbook();
String filename = “Excel2007Blank.xlsx”;
File excel2007File = new File(filename);
if (excel2007File.exists())
{
workbook.open(filename, FileFormatType.EXCEL2007);
Worksheets worksheets = workbook.getWorksheets();
}
}
catch (IOException e)
{
System.out.println(“Exception when opening Excel 2007 workbook:\n”+ e);
}
}
I am using Java 1.5.0_04. The classpath contains Aspose.Cells.jar and dom4j-1.6.1.jar. A blank Excel 2007 sample file is attached inside a zip file.

Lothar

Hi Lothar,

There do has a bug when reading blank excel file for 2007, please try the attached fix. Thank you.

Your fix works. Thanks a lot for all your efforts.