我需要使用AngularJS(使用1.5.x版)將數據導出到Excel工作表 我嘗試使用FileSaver.js和Alasql從下面給定鏈接的溶液導出數據到XLS在正確的格式使用Angularjs
我有兩個問題。
- 我需要在Excel中的數據被定製爲在下面的截圖:
所需加粗標頭和分開的列在表上,我可以實現使用的頂FileSaver,但它導致了第二點。
Javascript & HTML Code -
$scope.getFile = function() {
var blob = new Blob([document.getElementById('exportable').innerHTML], {
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"});
saveAs(blob, "ProgramsInfo.xls");
}
<a ng-click="getFile()" file-download="myBlobObject">Download Report</a><a>Share</a>
<div id="exportable" style="display:none;">
<table width="100%" border="1">
<thead>
<tr><td>Client : {{client}}</td></tr>
<tr><td>Program : {{programName}}</td></tr>
<tr><td>Date Range : {{dateRange}}</td></tr>
<tr>
<th>Name</th>
<th>E-mail</th>
<th>DoB</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="program in programs">
<td>{{program.account_name}}</td>
<td>{{program.e_mail ? 'Y':'N'}}</td>
<td>{{program.dob | date:'MM/dd/yy'}}</td>
</tr>
</tbody>
</table>
</div>
- 使用Firefox其中指出
The file you are trying to open is in a different format than specified by the file extension...
![] [火狐錯誤消息] 2時獲得的誤差
任何人都可以幫助我?
我建議你應該可以發佈您的努力Kritika一個更好的幫助升技。 –