Jsp to formatted Excel

<%
response.setContentType(“application/vnd.ms-excel”);
response.addHeader(“Content-disposition”, “attachment; filename=export.xls” );
%>
<html xmlns:o=”urn:schemas-microsoft-com:office:office”
xmlns:x=”urn:schemas-microsoft-com:office:excel”
xmlns=”http://www.w3.org/TR/REC-html40″&gt;
<head>
<style>
.numWithoutDec {mso-number-format:”\#\,\#\#0″;text-align:right;}
.numWith2Dec {mso-number-format:Standard;text-align:right}
.date {mso-number-format:”mm\/dd\/yyyy\;\@”}
</style>
</head>
<body>
<table x:str border=”1″>
<tr>
<th>String</th>
<th>Number 1</th>
<th>Number 2</th>
<th>Date</th>
</tr>
<tr>
<td x:str=”abcd”></td>
<td x:num=”12345.67″ class=”numWithoutDec”></td>
<td x:num=”12345.67″ class=”numWith2Dec”></td>
<td x:num=”36230″ class=”date”></td>
</tr>
</body>
</html>

export.jpg

Date number 36230 is the days between 01/01/1900 and 03/11/1999

Advertisements

1 Comment »

  1. Arya Stark said

    Thanks for your post :) But I want to something, how can I show numbers like “987.569.256,69”, that is, it should be like dot,dot and comma.

RSS feed for comments on this post · TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: