使用ng-bindhtml导出xls文件中的表

export table in xls file with ng-bindhtml

本文关键字:文件 xls ng-bindhtml 导出 使用      更新时间:2023-09-26

当我在下面的表上使用这个函数时。

var blob = new Blob([document.getElementById('exportable').innerHTML], {
            type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"
        });
        saveAs(blob, $scope.name+".xls");

<div id="exportable">
<table border="1" width="100%">
    <thead>
    <td>Question</td>
    <td>Answer</td>
    </thead>
    <tbody>
    <tr data-ng-repeat="q in ques">
    <td>{{q.Title}}</td>
    <td ng-bind-html="answers[$index+1]"></td>
    </tr>
    </tbody>
</table>
</div>

excel文件如下这个

每一行前面都会多加一个"。如何删除它

我使用了这个脚本

for(var i=0;i<ans.length;i++){
    ans[i] = ans[i]..replace(/'u200B/g,'');
}