Link to home
Start Free TrialLog in
Avatar of mkarthik415
mkarthik415

asked on

How to export table from the jsp to an excel sheet

I have displayed in the jsp
<table>
      <TR>
      <TD><%=i+1 %></TD>
      <TD><%= Obect.getRollNo()%></TD>
      <TD><%=Obect.getName()%></TD>
      <TD><%= Obect.getClass()%></TD>
      <TD><%= Obect.getSchool()%></TD>
      </TR>
      <% i++;
}%>
</table>

How can I export to an excel sheel when clicked on a button

Thank you.
ASKER CERTIFIED SOLUTION
Avatar of Gurvinder Pal Singh
Gurvinder Pal Singh
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of a_b
a_b

In the JSP when the button is clicked, read the values of the table in a loop and write that to a comma seperated values file. That is the simplest solution.
Avatar of mkarthik415

ASKER

i have created a new jsp which has this code
<%
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition", "attachment; filename=\"x.xls\"");
%>

when click on a button new excel file open but empty data how do I put my tables in his jsp so that the excel file has that data
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
When put it like what u have suggested dravidnsr, I get the data but with no column or rows in excel sheet
x.xls
r u using
follwing thing in ur jsp

 <style name="header" fontColor="green" fontWeight="bold"
         foreground="#C9C9C9" fillPattern="solid-foreground"/>
  <style name="highlight" border="medium-dashed" borderColor="blue"/>

then its return as no borders only ....

remove this code in ur jsp and try !!
<cell > realated anything in jsp ????????
there is nothing related to cell or style tag in my jsp
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
TY