1
0

perf: Do not read worksheet twice

This commit is contained in:
2026-03-25 10:41:24 +01:00
parent 86f71bf178
commit 448b565835
3 changed files with 11 additions and 12 deletions
+2 -6
View File
@@ -15,7 +15,7 @@
import fs from "fs";
import parseAbsence from "../utils/parseAbsence.js"
import parseTeachers from "../utils/parseTeachers.js"
import ExcelJS, { Worksheet, Cell, Row } from "exceljs"
import ExcelJS, { Worksheet, Cell, Row, Workbook } from "exceljs"
import JSZip from "jszip";
import { parseStringPromise } from "xml2js";
@@ -42,8 +42,6 @@ async function getThemeColors(filePath: string): Promise<ThemeColors | null> {
const data = fs.readFileSync(filePath);
const zip = await JSZip.loadAsync(data);
// list all files for debug
const themeFile = zip.file("xl/theme/theme1.xml");
if (!themeFile) {
return null;
@@ -118,9 +116,7 @@ function resolveCellColor(cell: Cell, themeColors: ThemeColors | null) {
return null;
}
export default async function parseV3(downloadedFilePath: string) {
const workbook = new ExcelJS.Workbook();
await workbook.xlsx.readFile(downloadedFilePath);
export default async function parseV3(workbook: Workbook, downloadedFilePath: string) {
const themeColors = await getThemeColors(downloadedFilePath);
const teacherMap = await parseTeachers();