sample excel
This commit is contained in:
parent
13d1a5699a
commit
fa996a6be6
|
|
@ -30,6 +30,7 @@ import { TaxInvestment } from "../../_models/Payroll/Tax/taxInvestment";
|
|||
import { AttendanceServices } from "../../_services/attendance/attendance.service";
|
||||
import * as fileSaver from "file-saver";
|
||||
import * as XLSX from "xlsx";
|
||||
import * as ExcelJS from "exceljs";
|
||||
import { TaxParameter } from "../../_models/Payroll/Tax/taxParameter";
|
||||
import { OpiService } from "../../_services/payroll/opi.service";
|
||||
import { OpiItem } from "../../_models/Payroll/opiItem";
|
||||
|
|
@ -1016,15 +1017,32 @@ export class DataUploadComponent implements OnInit, OnDestroy {
|
|||
//const workbook: XLSX.WorkBook = { Sheets: { 'data': worksheet }, SheetNames: ['data'] };
|
||||
|
||||
//new
|
||||
const workbook = XLSX.utils.book_new();
|
||||
const workSheet = XLSX.utils.json_to_sheet(cols);
|
||||
XLSX.utils.book_append_sheet(workbook, workSheet, this.sheetName);
|
||||
//const workbook = XLSX.utils.book_new();
|
||||
//const workSheet = XLSX.utils.json_to_sheet(cols);
|
||||
//XLSX.utils.book_append_sheet(workbook, workSheet, this.sheetName);
|
||||
//const excelBuffer: any = XLSX.write(workbook, {
|
||||
// bookType: "xlsx",
|
||||
// type: "array",
|
||||
//});
|
||||
//this.saveAsExcelFile(excelBuffer, this.sheetName);
|
||||
|
||||
const excelBuffer: any = XLSX.write(workbook, {
|
||||
bookType: "xlsx",
|
||||
type: "array",
|
||||
// Same sheet name, same header row in the same order and same file name as before; the only
|
||||
// difference is that mandatory columns (allowNull = "NO", the ones shown red on the page) get a
|
||||
// red header. Built with exceljs because the community xlsx build cannot write cell colours.
|
||||
const workbook = new ExcelJS.Workbook();
|
||||
const workSheet = workbook.addWorksheet(this.sheetName);
|
||||
const headerRow = workSheet.addRow(this.test.columnName);
|
||||
this.test.columnName.forEach((col, index) => {
|
||||
const allowNull: string = this.test.allowNull ? this.test.allowNull[index] : null;
|
||||
const mandatory = !!allowNull && allowNull.toUpperCase() == "NO";
|
||||
// every header bold; mandatory ones also red
|
||||
headerRow.getCell(index + 1).font = mandatory ? { bold: true, color: { argb: "FFFF0000" } } : { bold: true };
|
||||
// each column as wide as its own header text (+ a little room for bold text)
|
||||
workSheet.getColumn(index + 1).width = Math.max(String(col ?? "").length + 4, 8);
|
||||
});
|
||||
workbook.xlsx.writeBuffer().then((excelBuffer: any) => {
|
||||
this.saveAsExcelFile(excelBuffer, this.sheetName);
|
||||
});
|
||||
this.saveAsExcelFile(excelBuffer, this.sheetName);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
/* Required-field marker on the fields themselves. Not on wrapper <div [formGroup]>s (inside the
|
||||
employee / cost-center pickers): they turn ng-invalid whenever any field is, which drew a second red line. */
|
||||
:host ::ng-deep .ng-invalid:not(form):not(div) {
|
||||
border-left: 2px solid var(--gh-dn);
|
||||
/* Fields keep their own left border (the app-wide required marker); this page adds none of its own.
|
||||
The wrapper <div [formGroup]> inside the employee / cost-center pickers turns ng-invalid whenever any
|
||||
field is, and assets/forms.css would give it a red left border too — a second line next to the
|
||||
field's own. So the wrapper gets no border. */
|
||||
:host ::ng-deep div.ng-invalid:not(form) {
|
||||
border-left: none;
|
||||
}
|
||||
|
||||
/* Header: Employee, Effect Date, Cost Center, Involvement and Add on one row (layout only, palette colours) */
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user