This commit is contained in:
icssoa 2023-06-02 16:22:59 +08:00
parent a83f2029e9
commit 9f37d489e9

View File

@ -139,14 +139,14 @@ function onUpload(raw: File, _: any, { next }: any) {
let data = ""; let data = "";
if (ext == "csv") { if (ext == "csv") {
const detected = chardet.detect(new Uint8Array(event.target.result)); const detected: any = chardet.detect(new Uint8Array(event.target.result));
const decoder = new TextDecoder(detected); const decoder = new TextDecoder(detected);
data = decoder.decode(event.target.result); data = decoder.decode(event.target.result);
} else { } else {
data = event.target.result; data = event.target.result;
} }
const workbook = XLSX.read(data, { type: "binary" }); const workbook = XLSX.read(data, { type: "binary", raw: ext == "csv" });
let json: any[] = []; let json: any[] = [];
for (const sheet in workbook.Sheets) { for (const sheet in workbook.Sheets) {