我正在尝试“导出到Excel”功能,这是我的功能:
$scope.OpenigStockexportToExcel = function () {
debugger
var data = CreateTableView($scope.GetOpeningStockDetailsReport, 'table', true);
var blob = new Blob([data], {
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"
});
saveAs(blob, "OpeningStockDetailsReport.xls");
}
获得的结果如下:
<table class="table">
<thead>
<tr><th scope="col">Date</th><th scope="col">Location</th><th scope="col">VNo</th><th scope="col">ProductName</th><th scope="col">UOMName</th><th scope="col">Qty</th><th scope="col">Cost</th><th scope="col">Amount</th><th scope="col">SumQty</th><th scope="col">SumAmount</th><th scope="col">$$hashKey</th></tr>
</thead>
<tbody>
<tr class="alertnate"><td>10-11-2015</td><td>Dist</td><td>OS33</td><td>Priority</td><td>No's</td><td>4</td><td>2.5</td><td>10</td><td>68</td><td>302</td><td>OS49</td><td>Test 13</td><td>No's</td><td>5</td><td>5</td><td>25</td><td>68</td><td>302</td><td>object:303</td></tr><tr><td>18-11-2015</td><td>hari</td><td>OS50</td><td>Test 133d</td><td>No's</td><td>3</td><td>3</td><td>9</td><td>68</td><td>302</td><td>object:304</td></tr>
</tbody>
</table>
我需要删除以下元素:
<th scope="col">$$hashKey</th>
...和
<td>object:303<td>
值..
答案 0 :(得分:0)
在传递给生成表之前从对象中删除$$hashkey
。
像
$scope.OpenigStockexportToExcel = function () {
debugger
// Delete hash key here from $scope.GetOpeningStockDetailsReport
delete $scope.GetOpeningStockDetailsReport.$$hashKey;
var data = CreateTableView($scope.GetOpeningStockDetailsReport, 'table', true);
var blob = new Blob([data], {
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"
});
saveAs(blob, "OpeningStockDetailsReport.xls");
}
我希望它有效。