38 lines
1.4 KiB
JavaScript
38 lines
1.4 KiB
JavaScript
import fs from "node:fs/promises";
|
|
import { FileBlob, SpreadsheetFile } from "@oai/artifact-tool";
|
|
|
|
const inputPath = "C:/Users/milu/OneDrive - Exxeta/Dokumente/Assessor Zeiterfassung/ASSESSOR_Zeiterfassung_Sep2026_Jul2027_Form_wie_vorher.xlsx";
|
|
const outputDir = "C:/Users/milu/OneDrive - Exxeta/Dokumente/VS CODE/ASSESSOR-2-5/outputs/01a089e9-f688-7f21-87c9-db223e98841f";
|
|
|
|
const workbook = await SpreadsheetFile.importXlsx(await FileBlob.load(inputPath));
|
|
const overview = await workbook.inspect({
|
|
kind: "workbook,sheet,table,definedName,drawing",
|
|
maxChars: 12000,
|
|
tableMaxRows: 8,
|
|
tableMaxCols: 10,
|
|
tableMaxCellChars: 100,
|
|
});
|
|
console.log(overview.ndjson);
|
|
|
|
const sheets = workbook.worksheets.items;
|
|
for (const sheet of sheets) {
|
|
const used = sheet.getUsedRange();
|
|
console.log(`SHEET\t${sheet.name}\t${used?.address ?? "(empty)"}`);
|
|
if (used) {
|
|
const region = await workbook.inspect({
|
|
kind: "region,formula,computedStyle",
|
|
sheetId: sheet.name,
|
|
range: used.address,
|
|
maxChars: 10000,
|
|
tableMaxRows: 45,
|
|
tableMaxCols: 12,
|
|
tableMaxCellChars: 120,
|
|
options: { maxResults: 120 },
|
|
});
|
|
console.log(region.ndjson);
|
|
const preview = await workbook.render({ sheetName: sheet.name, autoCrop: "all", scale: 1, format: "png" });
|
|
const safe = sheet.name.replace(/[^a-z0-9_-]+/gi, "_");
|
|
await fs.writeFile(`${outputDir}/preview_${safe}.png`, new Uint8Array(await preview.arrayBuffer()));
|
|
}
|
|
}
|