const fs = require("fs");
const AdmZip = require('adm-zip'); //引入查看zip文件的包
let chooser = document.getElementById("readFile");
chooser.addEventListener("change", function (evt) {
let filePath = this.value.toString();
document.querySelector("p").innerHTML = "读取文件从" + filePath;
const zip = new AdmZip(filePath); //filePath为文件路径
let contentXml = zip.readAsText("word/document.xml");//将document.xml读取为text内容;
let str = "";
contentXml.match(/<w:t>[/s/S]*?<//w:t>/ig).forEach((item)=>{
str += item.slice(5,-6)}
);
console.log(str)
})
原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/147596.html