Charts 谷歌表格图表导出为PDF格式,带有自动表格
嗨,我正在尝试将谷歌表格导出为PDF格式。我试过这样做:Charts 谷歌表格图表导出为PDF格式,带有自动表格,charts,google-visualization,Charts,Google Visualization,嗨,我正在尝试将谷歌表格导出为PDF格式。我试过这样做: var doc = new jsPDF('p','pt','a4'); doc.text(15, 15, 'Batemo Cell Finder Report'); // doc.addImage(ScatterChart.getChart().getImageURI(), 15, 40, 180, 160); doc.autoTable(document.getElementById("t
var doc = new jsPDF('p','pt','a4');
doc.text(15, 15, 'Batemo Cell Finder Report');
// doc.addImage(ScatterChart.getChart().getImageURI(), 15, 40, 180, 160);
doc.autoTable(document.getElementById("table_div"), 15, 15, {
'width': 200,
'elementHandlers': specialElementHandlers,
});
doc.save('chart.pdf');
但它在浏览器中显示以下控制台错误:
Uncaught TypeError: Cannot create property 'body' on number '15'
at parseUserArguments (jspdf.plugin.autotable.js:1276)
at Object.parseInput (jspdf.plugin.autotable.js:1195)
at Object.autoTable (jspdf.plugin.autotable.js:1154)
at HTMLInputElement.<anonymous> (cell_finder.html:287)
Uncaught TypeError:无法在数字“15”上创建属性“body”
在parseUserArguments处(jspdf.plugin.autotable.js:1276)
在Object.parseInput(jspdf.plugin.autotable.js:1195)
在Object.autoTable(jspdf.plugin.autoTable.js:1154)
在HTMLInputElement。(cell_finder.html:287)
如何显示数据。非常感谢 谷歌表格图表确实生成了一个普通的html
但是,它包含在一个或多个
元素中
可能autotable
需要一个表元素,而不是div
尝试直接提供表元素
doc.autoTable(document.querySelector('#table_div table')[0], 15, 15, {
'width': 200,
'elementHandlers': specialElementHandlers,
});
它不起作用。它仍然会产生相同的错误。我尝试了另一种方法:doc.autoTable({head:[[data.getColumnLabel(0),data.getColumnLabel(1),data.getColumnLabel(2),data.getColumnLabel(3),data.getColumnLabel(4)],body:[data.getFilteredRows],});标题有效,但我不知道如何获取表中已筛选行的数据。下面的行最终有效:doc.autoTable({html:document.querySelector('#Table_div Table');