Saving XLSX File get corrupted when using ASPOSE.CELLS for Java 2.1.1

Hi,

I have problem when I set a cell value and then save the worksheet that is the file is getting corrupted only if it is Excel 2007 format. In the line saving the excel file (workbook.save(“C:/Worksheet.xlsx”, FileFormatType.EXCEL2007):wink: the system creates an exception with the following message: “error in opening zip file”.

Here is the code:

import com.aspose.cells.Cells;
import com.aspose.cells.FileFormatType;
import com.aspose.cells.Workbook;
import com.aspose.cells.Worksheet;
import com.aspose.cells.Worksheets;
import java.io.IOException;
public class ExcelTest {
public static void main(String[] args){
Workbook workbook = new Workbook();
try {
workbook.open(“C:/Worksheet.xlsx”);
} catch (IOException e) {
System.out.print(e.getMessage());
}
Worksheets worksheets = workbook.getWorksheets();
Worksheet sheet = worksheets.getSheet(0);
Cells cells = sheet.getCells();
cells.getCell(1, 1).setValue(“MOSD REFERENCE”);

//2003 format (Working fine)
// workbook.save(“C:/Worksheet.xlsx”);

//2007 format
try {
workbook.save(“C:/Worksheet.xlsx”, FileFormatType.EXCEL2007);
} catch (IOException e) {
System.out.print(e.getMessage());
}

}
}


The error message that I got when I try to open the Excel file after saving is:

"Excel cannot open the file “worksheet.xlsx” because the file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file."

Please advise.

Best Regards,
Omar

Hi,

Thank you for considering Aspose.

Well, I tested your issue with the attached latest version of Aspose.Cells and it works fine. Please try the attached latest version of Aspose.Cells for Java. If you still face any problem, please share your template and generated files and we will check it soon.

Thank You & Best Regards,

Hi,

Thank you for the update. I have downloaded and used the latest release of the component. But still getting the same error message.

I’m attaching the java class with the excel file before and after saving. Just try to run it on a blank excel sheet with 2007 format.

Many Thanks,
Omar

Hi Omar,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for considering Aspose.

I tried your template file and sample code with the latest version and it works fine( Attached is the resultant file). Please make sure that you are using the latest Aspose.Cells.jar file provided in the previous post. You may use CellsHelper.getReleaseVersion() API in your code to check which version you are using.

We will also look into the corrupt file and see if we can identify the cause of your issue.

Thank you & Best Regards,

Hi Nausherwa,

I used the CellsHelper.getReleaseVersion() API to verify the version that Iam using and it shows 2.1.1.16. The same code is working completely fine with 2003 format (xls).

If I use workbook.save(“C://Worksheet.xlsx”,FileFormatType.EXCEL2007); for saving the file then the following exception will occur: “java.io.IOException: error in opening zip file” and the file will be corrupted. While when using workbook.save(“C://Worksheet.xlsx”); no exception will occur and the file will be corrupted.

Is this related to the version of the dom library attached where, it is the same file downloaded from ASPOSE CELL DEMO files dom4j-1.6.1.jar?

Best Regards,
Omar

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for considering Aspose.

We have found your mentioned issue after further testing. We will look into it and get back to you soon. Your issue has been registered in our internal issue tracking system with issue id CELLSJAVA-13386.

Thank you & Best Regards,

Hi Omar,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for considering Aspose.

Please try the attached latest version of Aspose.Cells. We have fixed your mentioned issue.

Thank you & Best Regards,

Hi Nausherwan,

Thank you for the update.

This release fixes the issue with 2007 format. But I got another problem with this release 2.1.1.17 which was fine with release 2.1.1.16 which is adding some text to the header (PageSetup):

PageSetup pageSetup = worksheet.getPageSetup();
pageSetup.setCenterHeader(“Some text”);


The above code is working fine with 2007 format but not with the 2003 with the latest received release 2.1.1.17. It will corrupt the file and will not add any thing to the header as it was with the previous release.

I’m attaching the source code, the Excel file and the received error message.

Thanks & Regads,
Omar

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for considering Aspose.

We have found your mentioned issue after an initial test. We will look into it and get back to you soon. Your issue has been registered in our internal issue tracking system with issue id CELLSJAVA-13403.

Thank you & Best Regards,

Hi,

Please try the attached version. We have fixed your mentioned issue.

Thank you.

Hi Amjad,

Thank you for the update. This release fixes the reported issues.

Best Regards,
Omar

The issues you have found earlier (filed as 13386;13403) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.