修复前端解析csv 某些文件解码错误问题

修复前端解析csv 某些文件解码错误问题

Signed-off-by: 高雄 <admin@cxcp.com>
pull/281/head
高雄 8 months ago committed by Gitee
parent ebd35803c6
commit c3155204eb
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

@ -9,7 +9,6 @@
<script src="xspreadsheet/is-utf8.js"></script>
<script src="xspreadsheet/xlsx.full.min.js"></script>
<script src="xspreadsheet/xlsxspread.min.js"></script>
<script src="xspreadsheet/cptable.full.js"></script>
<script src="xspreadsheet/zh-cn.js"></script>
<script src="js/base64.min.js" type="text/javascript"></script>
</head>
@ -55,11 +54,19 @@ reader.onload = function(e) {
data = new Uint8Array(data);
let f = isUTF8(data);
if (f) {
try {
var str = cptable.utils.decode(65001, data);
process_wb(XLSX.read(str, { type: "string" }));
} catch (error) {
process_wb(XLSX.read(data));
}
} else {
try {
var str = cptable.utils.decode(936, data);
process_wb(XLSX.read(str, { type: "string" }));
} catch (error) {
process_wb(XLSX.read(data));
}
}
};
reader.readAsArrayBuffer(file);

Loading…
Cancel
Save