0

我正在使用带有 MVC 的 spring 也用于呈现的 jsp 页面。我要求允许最终用户下载在 jsp 中显示为 excel 表的表格。这些表包含我通过使用模型映射属性进行渲染,如下所示。

<div id="hotel_user">
<table width="98%" style="border:5px solid #999999" cellpadding="0" cellspacing="1" bgcolor="#CFD7E8">
<tr style="background-color:#72E076">
  <td width="auto" height="27" align="center">Date</td>
</tr>
<tr>
 <td width="0%" height="27" align="center" class="row2"><b>${aff.date_string}</b></td>
 <td width="auto" height="27" align="center"><b>${aff.no_of_posted} </b></td>
 <td width="auto" height="27" align="center"><b>${aff.no_of_listed}</b> </td>
</tr>
</table>
</div> 
  <input type="button" id="download" value="Download As Excell">

单击按钮时,表数据应下载为 excel。我已经看到并尝试实现代码,它在 excel 表中下载但 conatin null vale。以下链接我已经实施。 http://jsfiddle.net/n9XRx/

我在jquery中使用过:

 $("#download").click(function() {  
 var hotel_user = $('#hotel_user').html();    
 window.open('data:application/vnd.ms-excel,' + $('#hotel_user').html());
});     

任何建议我都犯了错误。谢谢。

4

1 回答 1

0

您首先需要一种将 html 表格中的数据转换为 excel 文档的方法。从这个开始 您必须在服务器端生成文档,然后您才能启动正确的下载。

于 2012-08-18T11:57:57.057 回答