0
我知道DOCX文件本质上是一个包含XML文件的zip文件。有没有使用chrome.fileSystem存储API来保存DOCX文件的简单方法,还是我需要手动创建和打包XML文件?Chrome应用程序Javascript:将文本另存为DOCX文件
chrome.fileSystem.chooseEntry({
type: 'saveFile',
accepts: [
{ extensions: ['docx'] },
{ extensions: ['txt'] },
]
}, function(writableFileEntry) {
var ext = writableFileEntry.name.substr(writableFileEntry.name.lastIndexOf('.') + 1);
var text = document.getElementById("textarea").innerText;
if(ext == 'docx'){
... ?
}
else if(ext == 'txt'){
writableFileEntry.createWriter(function(writer) {
writer.write(new Blob([text], {type: 'text/plain'}));
}, function(){
window.alert('Saving file failed');
});
}
});