Exporting Table in JSP into Excel

Hi,

I’m having problems after saving table information into Excel, whereby information in excel is not as per table information. Example, a string of “00001” is seen as 1 in Excel and also a string “THC-OH- =<15” is seen as “THC-OH- =<”. I’m coding the table details contents using String variable as below :

<% response.setContentType(“application/vnd.ms-excel”); %>
<% response.setHeader(“Content-Disposition”,“attachment; filename=” test.xls" ); %>

.
.

String ivnumber = rs.getString(1);

<td class=“content” ><%= ivnumber%></td>
<td class=“content” ><%= ivdescription%></td>
<td class=“content” ><%= dateadd%></td>

Is there a way to format the contents to be inserted into Excel correctly? I’ve search all over the net but could not find any possible solution.

Thank you.

In Apache POI you can do that.

http://poi.apache.org/spreadsheet/quick-guide.html#CellTypes

Thank you. I will look into this method.

this is an wild guess but try this

don’t put 00001, put double/single quotes around it ‘00001’ or “00001”

It’s obvious what the problem is for THC-OH- =<15, you need to covert this into HTML encoding.