嘿相關答案上Can I write files with HTML5/JS?的Javascript編寫成PDF或Excel
我怎麼會修改本作的發言權Excel或PDF。我嘗試過,但無法讓它工作。當我將MIME更改爲應用程序時,我下載了一個損壞的文件/ pdf
我試圖將它鏈接到存儲在localstorage中的數據,這些數據都存儲在變量中。
我當前的代碼是:
function setSaveFile(contents, file_name, mime_type) {
var a = document.getElementById('save');
mime_type = mime_type || 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; // text/html, image/png, et c
if (file_name) a.setAttribute('Log.xls', file_name);
a.href = 'data:'+ mime_type +';base64,'+ btoa(contents || 'Description' + ' ' + 'Notes' + ' ' + 'Date\n\n' + pdftimeLog);
}
我希望能夠將它與每個這些標題的導出爲CSV:DATE,說明,注意事項在不同的細胞。我希望它移動友好。謝謝
你可以發佈你到目前爲止嘗試過的代碼嗎? – jszumski 2013-05-09 01:21:45