Skip to content

Commit 8908dd9

Browse files
committed
fix: import excel file bug
1 parent 5e98093 commit 8908dd9

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

src/ExcelView.ts

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export class ExcelView extends TextFileView {
5151
// console.log("saveData", this.data)
5252
this.save(false)
5353
.then(() => {
54-
// console.log("save data success", this.file)
54+
console.log("save data success", this.file)
5555
})
5656
.catch((e) => {
5757
console.log("save data error", e)
@@ -86,11 +86,12 @@ export class ExcelView extends TextFileView {
8686
}
8787
const f = files[0];
8888
const reader = new FileReader();
89+
const self = this
8990
reader.onload = (e) => {
9091
const data = e.target?.result;
91-
console.log('handleFile', this.file)
92+
console.log('handleFile', self.file)
9293
if (data) {
93-
this.process_wb(XLSX.read(data));
94+
self.process_wb(XLSX.read(data));
9495
} else {
9596
new Notice(t("READ_FILE_FAILED"));
9697
}
@@ -102,16 +103,7 @@ export class ExcelView extends TextFileView {
102103
const sheetData = stox(wb);
103104
if (sheetData) {
104105
this.sheet.loadData(sheetData)
105-
console.log("getdata", this.sheet.getData())
106-
this.data = this.headerData() + JSON.stringify(sheetData);
107-
// console.log("saveData process_wb", this.file)
108-
this.save(true)
109-
.then(() => {
110-
console.log("save data success")
111-
})
112-
.catch((e) => {
113-
console.log("save data error", e)
114-
})
106+
this.saveData(JSON.stringify(sheetData))
115107
} else {
116108
new Notice(t("DATA_PARSING_ERROR"));
117109
}

0 commit comments

Comments
 (0)