@tucmc/hazel
Version:
Clubs Data Processing Framework
39 lines (38 loc) • 1.35 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.basicExcel = void 0;
const lib_1 = require("../lib");
const Workbook_1 = require("../lib/builtin/data/Workbook");
const Worksheet_1 = require("../lib/builtin/data/Worksheet");
const basicExcel = async (debug) => {
const evalColl = new lib_1.FirestoreCollection('evaluate');
const evalData = await evalColl.readFromCache(true);
if (!evalData)
return;
const evalRecords = new lib_1.ClubRecord(evalData.getRecord());
const book = evalRecords.map((clubId, v) => {
const sheetData = new lib_1.DMap(v.data()).map((k, v) => ({
ID: k,
report: v.action
}));
return new Worksheet_1.Worksheet(sheetData).setName(clubId);
});
const workbook = new Workbook_1.Workbook(book);
workbook.setStyle((l, cell) => {
cell.border = {
top: { style: 'thin' },
left: { style: 'thin' },
bottom: { style: 'thin' },
right: { style: 'thin' }
};
if (l.r === 1) {
cell.font = { bold: true };
cell.alignment = { horizontal: 'center' };
}
if (l.c === 2) {
cell.alignment = { horizontal: 'center' };
}
});
workbook.save('evals.xlsx');
};
exports.basicExcel = basicExcel;