I need to export data to an excel sheet using AngularJS(using version 1.5.x) I tried using FileSaver.js and Alasql from the solution given in the below link
I have two problems.
- I need the data in excel to be customized as in below screenshot :
The required bold headers and separate rows on the top of the table I could achieve using FileSaver, but it leads to the second point.
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>
- Getting an error when using Firefox which states that
The file you are trying to open is in a different format than specified by the file extension...
![] [Firefox Error message]2
Can anyone help me with this?