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)
})


觉得有帮助的小伙伴右上角点个赞~

node 读取docx乱码问题_乱码

扫描上方二维码关注我的订阅号~