【发布时间】:2018-02-28 00:01:49
【问题描述】:
我已经编写了 javascript 函数来将 HTML 表格转换为 Excel(完成),但是当我尝试在谷歌表格中打开我导出的 excel 时,它给了我类似这样的响应
我需要在 prototype JS function 中进行哪些更改才能解决此问题
handleexportExcel :function(){
var self = this;
$(".monthly-payments-report-details #paymentExcelReport").unbind('click');
$(".monthly-payments-report-details #paymentExcelReport").click(function(e){
var payment_report_table_html = "<table border='2px'>";
var monthly_payment_report_table = document.getElementById('monthlyPaymentReportTable');
for(index = 0 ; index < monthly_payment_report_table.rows.length-1 ; index++)
{
payment_report_table_html += monthly_payment_report_table.rows[index].innerHTML+"</tr>";
}
payment_report_table_html += "</table>";
var anchor_html_excel = document.createElement('a');
anchor_html_excel.href = 'data:application/vnd.ms-excel' + ', ' + encodeURIComponent(payment_report_table_html);
anchor_html_excel.download = 'Payment Report_' + self.start_date + '_' + self.end_date + '.xls';
anchor_html_excel.click();
})
}
【问题讨论】:
标签: javascript html excel google-sheets