I have retrieved data from back end to jsp page. I have used MIME TYPE to export the same data to an excel sheet. But I have used the similar code written for retrieval of data into jsp page. i.e., I was using the same logic twice to retrieve the data, and hitting the data base twice. Is there any way to export the data to excel directly from jsp page, rather than hitting the database again. Pl let me know if any suggestions.
The question left is: is the eaten up memory space really worth a save in the DB hit?
That said, fooling the browser with an invalid content-type/disposition response header so that it opens the request in Excel isn't the way you should follow. There is no guarantee that it will work at all platforms, all browsers and all Excel versions. Use a real Java API for Excel files which can create real .xls files, for example Apache POI HSSF/XSSF. More easy is to send the data as a CSV file, every Excel version supports the CSV format. There are libraries out for this as well, e.g. OpenCSV, CSV4J, JavaCSV, etc. If you're smart, you could even write it yourself in only 30 lines of code.
posted 10 years ago
There are multiple reports being generated from the database and it is required to export to excel sheet for every individual report. so, it definitely counts the DB hits.
But currently, I am concerned to export the data that was already retrieved on the page to an excel sheet. I have done the same by adding a mime type for the same code as a seperate file.
But it was required to hit the database again in this scenario.
will there be any other option of using the data that was retrieved in the jsp as a cache to open an excel sheet with the same data?
Please suggest me with a proper option.
posted 10 years ago
Too bad that you still sticks in this wrong direction.
At any way, you have no other options. Either store it in memory or hit the DB again.
Doody calls. I would really rather that it didn't. Comfort me wise and sterile tiny ad:
how do I do my own kindle-like thing - without amazon