We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Issue in saving Excel in XLSX format in JBoss


The below code works fine in Weblogic

Workbook workbook = new Workbook(FileFormatType.XLSX);
workbook.save(new BufferedOutputStream(new FileOutputStream(“C:/paging/test.xlsx”)),SaveFormat.XLSX);

But the same code, when executed in JBOSS, the file is getting getting corrupted and couldn’t be opened. Below messaage appears when try to open xlsx file.

The file format or the file extension is not valid. Verify that the file has not been corrupted and that the file extension
matches the format of the file.

In my Jboss application,sometimes,after workbook.save, the file format is getting changed to xls from xlsx.
Though I set FileformatType to XLSX explicitly, Somehow, somewhere file format is getting changed to xls instead of xlsx.
Many times, I noticed the file format getting changed from 6 to 5 after workbook.save.

But this issue is not happening when I deployed the same code in Weblogic.

Kindly clarify. Thanks.


Thanks for using Aspose APIs.

Please first make sure you are using the most recent version. You can find the version of your Aspose.Cells on runtime by using the CellsHelper.getVersion() method and it should return you 17.10.0.

Please download the most recent version (i.e. Aspose.Cells for Java v17.10) from the given link.

Next thing, you save the workbook into byte array and then write the byte array into disk. Please see the following sample code and read its comments for better understanding. These steps should solve your issue.


//This line will print the Aspose.Cells version.
//Please make sure, you are using the most recent version
System.out.println("Aspose.Cells for Java v" + CellsHelper.getVersion());

//Create empty workbook
Workbook wb = new Workbook();

//Access first worksheet
Worksheet ws = wb.getWorksheets().get(0);

//Access the cell B7 and put the value
Cell cell = ws.getCells().get("B7");
cell.putValue("This is sample text.");

//Save the workbook in byte array output stream in xlsx format
ByteArrayOutputStream bout = new ByteArrayOutputStream();
wb.save(bout, SaveFormat.XLSX);

//Convert the byte array output stream to byte array
byte[] bts = bout.toByteArray();

//Write the byte array to disk
FileOutputStream fout = new FileOutputStream("f:/download/out.xlsx");