负责的后台管理系统有前端导出表格的功能
由于本机上没有office,一开始使用wps测都是好的
结果后来项目用office打开,乱码。。。。
相关导出的内容网上一大堆,我就不赘述了,上代码
let template =
`<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!--[if gte mso 9]>
<xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet>
<x:Name>${worksheet}</x:Name>
<x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions>
</x:ExcelWorksheet>
</x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]-->
</head>
<body>
<table>${this.formatTitle() +this.formatColums() + this.formatData()}</table>
</body>
</html>`;
重点就是加上那一句
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">