Tor*_*ben 5 javascript ms-word docx
我正在寻找一个 JavaScript 库,它可以读取.doc- 和.docx- 文件。重点只放在文本内容上。我对 MS-Word 文件中的图片、公式或其他特殊结构不感兴趣。
如果该库与 JavaScript FileReader 一起使用,那就太好了,如下面的代码所示。
function readExcel(currfile) {
var reader = new FileReader();
reader.onload = (function (_file) {
return function (e) {
//here should the magic happen
};
})(currfile);
reader.onabort = function (e) {
alert('File read canceled');
};
reader.readAsBinaryString(currfile);
}
Run Code Online (Sandbox Code Playgroud)
我通过互联网搜索,但我找不到我要找的东西。
您可以使用 docxtemplater 来实现此目的(即使通常,它用于模板化,它也可以只获取文档的文本):
const zip = new PizZip(content);
// This will parse the template, and will throw an error if the template is
// invalid, for example, if the template is "{user" (no closing tag)
const doc = new Docxtemplater(zip, {
paragraphLoop: true,
linebreaks: true,
});
const text = doc.getFullText();
Run Code Online (Sandbox Code Playgroud)
请参阅文档以获取安装信息(我是该项目的维护者)
但是,它只处理 docx,而不处理 doc
| 归档时间: |
|
| 查看次数: |
12193 次 |
| 最近记录: |