使用 colspan 导出 table 并在 angular js 中格式化
Exporting table with colspan and formatting in angular js
我在 angular js 中创建了一个页面,它使用 ng-repeat 标记填充 table 中的数据。我使用了一些格式和 colspan。我正在尝试以 pdf 格式导出 table。我尝试了以下方法:
htmltoCanvas:使用以下代码:
$scope.export = function(){
html2canvas(document.getElementById('exportthis'), {
onrendered: function (canvas) {
var data = canvas.toDataURL();
var pdf = new jsPDF('landscape','pt','letter');
pdf.addImage(data, 'JPEG', 0, 0);
pdf.save("download.pdf");
}
});
}
我面临的问题是:由于它将 table 转换为图像,我无法复制内容,而且如果 table 太大(超过一页)它给出一个空白的pdf。
- 我用的 jspdf 不支持 colspan,格式也丢失了。
请指教
找到了解决我的问题的方法。将其发布为答案,因为它可能会帮助遇到相同问题的人。我现在正在使用打印选项,因此我可以使用格式保存 div。
我在 angular js 中创建了一个页面,它使用 ng-repeat 标记填充 table 中的数据。我使用了一些格式和 colspan。我正在尝试以 pdf 格式导出 table。我尝试了以下方法:
htmltoCanvas:使用以下代码:
$scope.export = function(){ html2canvas(document.getElementById('exportthis'), { onrendered: function (canvas) { var data = canvas.toDataURL(); var pdf = new jsPDF('landscape','pt','letter'); pdf.addImage(data, 'JPEG', 0, 0); pdf.save("download.pdf"); } }); }
我面临的问题是:由于它将 table 转换为图像,我无法复制内容,而且如果 table 太大(超过一页)它给出一个空白的pdf。
- 我用的 jspdf 不支持 colspan,格式也丢失了。
请指教
找到了解决我的问题的方法。将其发布为答案,因为它可能会帮助遇到相同问题的人。我现在正在使用打印选项,因此我可以使用格式保存 div。