i have a jsp page that generates an html table dynamically and i want to export this table to excel on click of a button after the table has been viewed on the browser.
Solutions I have tried:
1)i read about the response.setContentType("application/vnd.ms-excel"),but how do i use a button to do this and export only that table and not any other data.
Now the only possible soln I feel is to somehow get only the table included in a new jsp and then use 1st option on the new page.But the problem is i don't know how to include only the table under div tag in a new jsp page?
Wish to get the solution soon.
I had tried exactly this,but it does not show the dynamicly gen result but instead displays the code with scriptlets that I had written in order to get the desired output.
Pl. somehow get a solution to include only a fragment of a page ie table in another jsp page like we use <jsp:include> or <@include> directive
May be you could do something like this
I have used scriptlets, but we should not. Better to use el, jstl.
posted 9 years ago
Thanks a lot Swastik for taking time and working on grey cells to find a solution.You solved my problem partially.
The problem is I have many reports to be generated containing these kind of tables and at the end on the last row I have computed the total and stuff like that.So I can't create a common loop structure for all the reports as shown in your page2.jsp
So what I wanted was a common page with response type set to excel which all these reports can refer.
Below is given a common code that I am using to print the reports.Notice the use of div tag.I want something similar to it to work for my export feature as well like a jsp that can include just the contents of the div tag,etc
Pl. find a solution soon ...
posted 9 years ago
Got the logic ---- Thanks to Swastik
What is that? Is that a mongol hoarde? Can we fend them off with this tiny ad?