Files
genesis-2/notebooks/excel/index.ts
T
Your Name 6a56356c39
Supa-backup / run_db_backup (push) Successful in 1m34s
Add Excel processing functionality with merge pattern application
- Introduced `index.ts` to read an Excel file and apply merge patterns to specified ranges.
- Created `lib.ts` with utility functions for column number conversion and merge pattern application.
- Updated execution counts in `carbone.ipynb` to reflect the new code structure.
2026-03-17 11:06:52 -06:00

43 lines
1.1 KiB
TypeScript

import ExcelJS from "exceljs";
import { applyMergePattern } from "./lib";
/* const inputFile = Bun.file("mapa.xlsx");
const inputBuffer = await inputFile.arrayBuffer();
const workbook = new ExcelJS.Workbook();
await workbook.xlsx.load(inputBuffer); */
const workbook = new ExcelJS.Workbook();
await workbook.xlsx.readFile("mapa.xlsx");
const sheetName = 'RÍGIDO-Anexo 2 (A)'
const sheet = workbook.getWorksheet(sheetName)
if (!sheet) {
throw new Error(`Workbook has no sheet named: ${sheetName}`);
}
const CICLOS = 9;
const matrizAsignaturas = {
startColumns: ["C", "I", "O", "U", "AA"],
firstStartRow: 8,
mergeWidthInColumns: 5,
mergeHeightInRows: 3,
mergeBlockCount: CICLOS,
rowStepBetweenBlocks: 14 - 8,
} as const;
const semestres = {
startColumns: ["A"],
firstStartRow: 7,
mergeWidthInColumns: 1,
mergeHeightInRows: 5,
mergeBlockCount: CICLOS,
rowStepBetweenBlocks: 13 - 7,
} as const;
applyMergePattern(sheet, matrizAsignaturas);
applyMergePattern(sheet, semestres);
const outputBuffer = await workbook.xlsx.writeBuffer();
await Bun.write("excel2.xlsx", outputBuffer);
const end = Bun.nanoseconds();