From d6f4b0ebaaf7b57123ad936b0ced76c0f4130104 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Tue, 21 Jun 2022 11:52:49 +0800 Subject: [PATCH] fix: diacritics are garbled issue --- .../templateParsers/ExcelTemplateAdapter.js | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/packages/nc-gui/components/import/templateParsers/ExcelTemplateAdapter.js b/packages/nc-gui/components/import/templateParsers/ExcelTemplateAdapter.js index 9202e4ab31..1bd0107d15 100644 --- a/packages/nc-gui/components/import/templateParsers/ExcelTemplateAdapter.js +++ b/packages/nc-gui/components/import/templateParsers/ExcelTemplateAdapter.js @@ -27,7 +27,25 @@ export default class ExcelTemplateAdapter extends TemplateGenerator { } async init() { - this.wb = XLSX.read(new Uint8Array(this.excelData), { type: 'array', cellText: true, cellDates: true }) + const options = { + cellText: true, + cellDates: true + } + if (this.name.slice(-3) === 'csv') { + this.wb = XLSX.read( + (new TextDecoder).decode(new Uint8Array(this.excelData)), + { + type: "string", + ...options + }); + } else { + this.wb = XLSX.read( + new Uint8Array(this.excelData), + { + type: 'array', + ...options + }) + } } parse() {