Hi,
I wanted to check, if workbook can be saved or retrieved using servlets without physically saving it on server disk. I want to avoid "WB.save(pathname);"
I mean can we just keep the excel in memory as a serialized object and then stream it to client UI, in a pop up window?
Any such sample would be helpful.
Regards,
Abhinav
Hi Abhinav,
Well, a workbook cannot be saved as serialized object, but we think you may just save the workbook to a byte[] buffer (streams) and transfer that buffer accordingly (by using your own code) for your needs. You may save the workbook to ByteArrayOutputStream (by Aspose.Cells APIs) and then transfer the saved data to client by using your own codes and then build workbook again from the data.
Thank you.
Hi,
Please let me know the correct code to save workbook in the Stream.
I have used following where response is HttpServletResponse.
response.setContentType("application/vnd.ms-excel");
response.addHeader("Content-Disposition", "attachment;filename=" + versionId + "" + workbook.getFileName() + ".xlsm;");
workbook.save(response.getOutputStream(), FileFormatType.XLSM);
Thanks,
Hiren
Hi Hiren,
Thanks for your posting and using Aspose.Cells for Java.
Yes, this is the correct code. It will send the workbook in xlsm format as attachment in the browser.
Let us know if you face any issue. We will look into it and help you asap.
Hi,
I have tried above code in my application.
The problem is the file being returnred seems to be corrupted.
It shows following window when we open it.
"Excel found unreadable content...Do you want to to recover contents of this workbook ?"
If i say yes some of the namerange gets removed from the file.
File size is diffrent when I save it as xls. File with XLS is bigger in size and i am able to open it easily but it gives issue sometime while running macro and we need to use XLSM format for our application..
Thanks,
Hiren
Hi Hiren,
Thank you for posting your problem in Aspose.Cells support forum.
You presented scenario could be due to the corrupt input file (if any) or due to a bug in Aspose.Cells API. This matter needs thorough investigation and correction, if issue is identified as a bug on the part of Aspose.Cells for Java. We would request you to please provide us a sample application replicating the issue along with template file (if any). Reviewing the requested information will help us to identify the problem cause, and we can quickly move forward towards the correction (if applicable).
Moreover, we have recently published Aspose.Cells for Java 7.7.2.3. Please give it a try in your environment to see if the latest build makes any difference. Please feel free to write back in case you face any difficulty or have more questions for us.