Formatting lost after workbook.save



Workbook workbook = new Workbook();
workbook.open(new ByteArrayInputStream(docBinaryView.getContent())); // Byte array has Excel file with multiple tabs
workbook.getWorksheets().removeSheet(0); // removing the first tab

ByteArrayOutputStream ms = new ByteArrayOutputStream();
workbook.save(ms, FileFormatType.EXCEL2003); // I tried default as well

save (ms.toByteArray());

I am loosing all the formatting. Please help me out.

Hi,

Thanks for your posting.

Please also attach your workbook, so that we could look into this issue.

please find the attached. Thsi is the excel that i am reading and getting as byte array, forma workbook and remove the first tab and save it back.

Hi,

Thanks for providing us the template file and code.

I have tested your issue with your sample file and found the issue as you have mentioned. I have logged your issue with an id: CELLSJAVA-27793. We will look into your issue soon.

Thank you.

Any update on this? I am working on a project which needs to be in uat by june 3rd.


thanks
Jimmy

Hi Jimmy,

We will try to fix your issue soon. Once I have any update I will let you know here. I have requested the concerned developer to provide an eta if it takes longer time a bit.

Thank you.

Hi,

We have fixed this issue. Please download Aspose.Cells for Java v2.5.3.8.

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


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

I’m having the same issue. Losing the formatting from multiple tabs from my Excel file when I call


Workbook workbook = new Workbook();
xlsByteInStream = new ByteArrayInputStream(xls.getContent());
workbook.open(xlsByteInStream);
Worksheets sheets = workbook.getWorksheets();

for (int i = 0; i < sheets.size(); i++) {
String currentSheetName = sheets.getSheetName(i);
Worksheet sheet = sheets.getSheet(i);
if (!tabNames.contains(currentSheetName)) {
sheets.removeSheet(i);
}
}

xlsByteOutStream = new ByteArrayOutputStream();
LOG.debug(“Saving workbook…”);
workbook.save(xlsByteOutStream, FileFormatType.EXCEL97TO2003);

My test file is attached

Hi,

Please download the latest version of Aspose.Cells for Java. I found, it is working fine. Below is my code example, you can see the output file generated by the code below in the attachment.

Download Link: Aspose.Cells for Java v2.5.4.10

Java


String path=“F:\Shak-Data-RW\Downloads\PreAspose.xls”;


Workbook workbook = new Workbook();

workbook.open(“F:\Shak-Data-RW\Downloads\PreAspose.xls”);


Worksheets sheets = workbook.getWorksheets();

sheets.removeSheet(1);

sheets.removeSheet(0);


workbook.save(path + “.java.xls”, FileFormatType.EXCEL97TO2003);