node 读取docx乱码问题
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(/[/s/S]*?/w:t>/ig).forEach((item)=>{
str += item.slice(5,-6)}
);
console.log(str)
})
热门推荐
10 分别发的祝福语简短
11 大外甥高考祝福语简短
12 小学毕业校长简短祝福语
13 搞工程发财祝福语简短
14 冬季祝福语男生文案简短
15 同事生子问候祝福语简短
16 退休文案寄语简短祝福语
17 送给自己的祝福语简短
18 简短祝福语毛笔字