Unable read xlsx file

I’ve downloaded the latest Aspose.Cells for Java (v 2.0) from Nov 17, 2008 and wrote a small test to open an existing Excel 2007 (xlsx) file. When I try to load any xlsx file (using loadData) I get an exception saying “It is not a valid excel file.” When I save the same Excel file as xls then I can read it. I’ve attached a sample file.

Hi,

Thank you for considering Aspose.

Workbook.LoadData() method does not support MS Excel 2007 file format at the moment. You can use Workbook.Open() method instead. Please see the following sample code in this regard,
Sample Code:

//Creating a Workbook object

Workbook workbook = new Workbook();

//Calling open method of Workbook object to open Excel 2007 xlsx file

workbook.open("C:\\ mytest.xlsx", FileFormatType.*EXCEL2007* );

// Perform your required operations

//Save in Excel 2007 format

workbook.save("C:\\ mytest_result.xlsx", FileFormatType.*EXCEL2007* );

Thank You & Best Regards,

Hi,

Please use Workbook.open() method instead for Workbook.loadData() may exclude the drawing objects, formatttings etc. I have tested it and it works fine. And we will also look into the issue regarding Wokbook.loadData() method.

Sample code:

//Instantiate a new Workbook.
Workbook workbook = new Workbook();
workbook.open("e:\\files\\mytest.xlsx");
//Get the first worksheet in the workbook.
Worksheet worksheet1 = workbook.getWorksheets().getSheet(0);
//Get the cells in the worksheet.
Cells cells = worksheet1.getCells();
cells.getCell(0,0).setValue("Hello World!");
//Save the excel file.
workbook.save("e:\\files\\outmytest1.xlsx",FileFormatType.EXCEL2007);
Thank you.

Hi Aslam,

I used the above code to open the Xlsx file but am getting the below error.

java.io.IOException: It is not a valid excel2007 file.null

at com.aspose.cells.Workbook.open(Unknown Source)

I have attached the Sample file for your reference.

Regards

Janakiraman

Hi Janakiraman,

Thanks for providing us the template file.

After an initial test we found the issue you have mentioned. We will look into it and get back to you soon.

Thank you.

Hi,

Thank you for considering Aspose.

After analyzing your provided template file, we thing your provided file is a nonstandard Excel 2007 file. Maybe the file is not created by MS EXCEL, because the zip file cannot be read by java’s zip api: java.util.zip.*, and there are some missing elements as compare to the standard xlsx file format. To process such file with Aspose.Cells, please use the attached new fix and add following JVM parameter to let Aspose.Cells use Apache’s zip API(org.apache.tools.zip.):

-DAspose.Cells.ZipTool=APACHE

Also, the lib for apache zip api(such as in org.apache.ant.jar) need to be added to classpath.

Thank You & Best Regards,

Hi Aslam,

Thanks for your response.

We tried with the option which you mention in the above post its working fine.

When we try to open the Xlsx file with image or chart in it , we are unable to open it.

The sample file is attached for your reference.

Regards

Janakiraman

Hi,

Thank you for considering Aspose.

We have found your mentioned issue after an initial test. This problem is also occurring due to the non-standard format file. We will further look into it and try to fix the issue soon.

Thank You & Best Regards,

Hi Aslam ,

Thanks for your response.

We are facing another issue in the same Xlsx file.

When i try to convert the XLSX file with Charts to XLS-2003 format

workbook.save(sFileOutput , FileFormatType.EXCEL2003);

the Chart is missing in the newly created file.

If possible , please provide us the solution in Java as well as in .Net

Regards

Janakiraman

Hi,

Thank you for considering Aspose.

We will look into your mentioned issue for both Aspose.Cells for .NET and Java versions and we will get back to you soon.

Thank You & Best Regards,

Hi,

For missing chart issue, we are working on the feature currently. At present, Aspose.Cells for Java only keeps the original data in 2007 Xlsx format and saves it back when saving as 2007 Xlsx format.

Thank you.

Hi Sahi,

Thanks for your Response.

When i can expect the Aspose Cells updated verion with this feature.

Both in .Net and Java.

Regards

Janakiraman

Hi,

For .NET, we will provide you the fix in 1-2 days

For Java, we will further analyze the feature and let you know soon.

Thank you.

Hi,

After we have investigated the feature, it is to inform you that Aspose.Cells for Java can support this feature in 2-3 months time.

Thank you.

Hi,

Thanks for your response.

May know the status of the id 173229 in the same post.

Regards

Janakiraman

Hi,

Thank you for considering Aspose.

Please try the attached latest version of Aspose.Cells. We have fixed your mentioned issue regarding opening a non-standard xlsx file ( issue id 173229).

Thank You & Best Regards,

Hi Aslam,

Thanks for your response.

Its working fine.Can you provide us the latest version in .Net too for this fix.

At same time we are waiting for the latest fix for Issue ID 173330 , as Amjad Sahi said that missing of Chart while converting from Xlsx 2007 to xls 2003 format can be fixed in 1-2 days in .Net in the Post ID 173735

Regards

Janakiraman.D

Hi,

Well, we are working on the fix for .NET version, we will attach the fix as soon as we fix it.

Thanks for being patient!

Hi ,

Any updates on missing chart issue fix for .Net Version.

Regards

Janakiraman

Hi,

Well, you may try our latest version: http://www.aspose.com/community/files/51/file-format-components/aspose.cells-for-.net-and-java/entry174461.aspx , we have fixed the missing chart issue in the generated xls file.

But there is still a color issue as the bars are not rendered with the same colors in the generated xls file, we will check it and get back to you soon.

Thank you.