私はSpringをMVCで使用しており、プレゼンテーション用の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シートにnull値が含まれています。以下のリンクをたどって実装しました。 http://jsfiddle.net/n9XRx/
私はjqueryで次のように使用しました:
$("#download").click(function() {
var hotel_user = $('#hotel_user').html();
window.open('data:application/vnd.ms-excel,' + $('#hotel_user').html());
});
どんな提案でも私は間違いを犯しています。ありがとう。