Hi all,
I want to open my Cells file which was saved by using this :
_response.setContentType(“application/vnd.ms-excel”);
_response.setHeader(“Content-Disposition”,“attachment; filename=“file”.xls”);
But it doesn’t work even if my cells file was succefully saved.
Thanks in advance
Hi,
We have forwarded your question to our development team. They will help you as soon as possible.
Hi,
Please try this code and see if it works fine. If you still encounter any problem, feel free to post again.
Java
String file = accBusinessController.getXlsFile(market,recty); // here I saved my file in a special directory
workbook.open(file);
ServletOutputStream outs = response .getOutputStream();
response.setContentType(“application/vnd.ms-excel”);
response.setHeader(“Content-Disposition”, “attachment; filename=sampleName.xls”);
workbook.save(outs);
outs.close();
Hi,
Thanks for your code example.
Actually, your issue is not related to Aspose.Cells, but it is related to JSP. You had already saved the excel file successfully by Aspose.Cells. You should search the answer in JSP and related output stream/writer.
Previously, you were just sending the file name to client and not the file content. You should first search for a code that will just send a simple file content to the client. For that purpose you can create Excel file manually too using MS-Excel. Once you are able to send file content to client, then embed your Aspose.Cells code inside it.
Thanks, I will change my code.
Hi mshakeel.faiz,
Since last time, I haven’t time to change my code. I will do today.
If I really understant what you suggest to me, I must do the same code to the client.
That is I must create a new worbook which contains the same worsheet, cells,…, that I had created in my DAO for my JSP?
Because, if I can open my file in my client service after saving it without create a file I will not need to use a download.
Thanks for your answer.
thanks babar.raza
I modified my code and I use this below but it doesn’t work. Even the dialog windows is not opened when I clicked on Run.
thanks
Hi,
No one can resolve this point with me?
I tried many solutions but impossible even to open this file without download.
I changed my release and I checked the directory where I saved my file and all is Ok, but I don’t have the dialog box, and any errors.
Is it really possible to have dialog box with Aspose?
Thanks
Hi,
Firstly I think you need to make your code work fine for downloading an existing file(without any reference to aspose.cells). And I am afraid your current code is invalid too when it be executed. From your code I think the file content has been sent to client twice in one same stream. Even the client can get the dialog and save the file, the file will be corrupted because of the duplicated data. I think you can remove the code using Aspose.Cells and then check whether you can get the file downloaded.
In fact I suspect that your code has never been executed so that you cannot get the dialog from client side. The most simple method to check it is that you add some log message such as System.out.println(…) in your code, if you cannot see those messages from your server, then there must have some problems in your code of processing client request.
Hi all,
I just want to thank you about all your proposal, now it’s working well.
Regards
Hi,
I need to use print writer instead of Servletoutputstream. how can i write work book content to print writer
Hi,
Thanks for using Aspose.Cells.
Well, this question does not seem to be related to Aspose.Cells but it is related to print writer class library.
If you can write any file (stream or its bytes) in print writer, then you can also write Aspose.Cells workbook object.
So, please search on the internet how to write any file in print writer. Once, you know how to achieve it, you can then save the workbook object into stream or bytes and write inside print writer too.