import * as XLSX from 'xlsx'; import { TrUtils } from '../../../../utils/tr-utils'; export class InvoicesWiseXlsxFileService { static wb: any = {}; static Row: any = 2; static MergeArray: any[] = []; static range = { s: { c: 0, r: 0 }, e: { c: 0, r: 0 } }; static ws: any = {}; static GetInvoiceWiseExcelData(MainData: any, WOTypes: any, EntitySettings: any) { this.wb={}; this.ws = {}; this.Row=0; this.range = { s: { c: 0, r: 0 }, e: { c: 0, r: 0 } }; this.MergeArray=[]; let ws_name = 'Invoices'; this.wb.Sheets = {}; this.wb.Props = {}; this.wb.SSF = {}; this.wb.SheetNames = []; MainData = this.GetTotals(MainData, WOTypes); this.setHeadingInCell(); this.setInvoiceDetailsInCell(MainData, EntitySettings.DecimalsNumber); this.ws['!ref'] = XLSX.utils.encode_range(this.range); this.ws['!merges'] = this.MergeArray; this.wb.SheetNames.push(ws_name); this.wb.Sheets[ws_name] = this.ws; return this.wb; } static GetTotals(MainData: any, WOTypes: any) { MainData.forEach((InvoiceInfo: any) => { if (InvoiceInfo.VIN == null) { InvoiceInfo.VIN = ''; } if (InvoiceInfo.Name == null) { InvoiceInfo.Name = ''; } if (InvoiceInfo.TeNa == null) { InvoiceInfo.TeNa = ''; } if (InvoiceInfo.Type == null) { InvoiceInfo.TypeName = ''; } else { InvoiceInfo.TypeName = this.GetWOTypeName(InvoiceInfo.Type, WOTypes); } // let CGST18: number = 0; // let SGST18: number = 0; // let CGST28: number = 0; // let SGST28: number = 0; // let Total18perc: number = 0; // let Total18perctax: number = 0; // let Total28perc: number = 0; // let Total28perctax: number = 0; // if(!TrUtils.IsNull(InvoiceInfo.Items) && InvoiceInfo.Items.length !==0){ // InvoiceInfo.Items.forEach((item: any) => { // if (item.TCode === 106) { // Total18perc=Total18perc+TrUtils.SetValueToZeroIfNull(item.UnAmt); // CGST18 = CGST18 + TrUtils.SetValueToZeroIfNull(item.CGST); // SGST18 = SGST18 + TrUtils.SetValueToZeroIfNull(item.SGST); // Total18perctax=Total18perctax+Total18perc+CGST18+SGST18; // } else if (item.TCode === 107) { // Total28perc=Total28perc+TrUtils.SetValueToZeroIfNull(item.UnAmt); // CGST28 = CGST28 + TrUtils.SetValueToZeroIfNull(item.CGST); // SGST28 = SGST28 + TrUtils.SetValueToZeroIfNull(item.SGST); // Total28perctax=Total28perctax+Total28perc+CGST28+SGST28; // } // }); // } // InvoiceInfo.Total18perctax = TrUtils.FixPriceValue(Total18perctax); // InvoiceInfo.Total28perctax = TrUtils.FixPriceValue(Total28perctax); // InvoiceInfo.Total18perc = TrUtils.FixPriceValue(Total18perc); // InvoiceInfo.Total28perc = TrUtils.FixPriceValue(Total28perc); // InvoiceInfo.Items18CGST = TrUtils.FixPriceValue(CGST18); // InvoiceInfo.Items18SGST = TrUtils.FixPriceValue(SGST18); // InvoiceInfo.Items28CGST = TrUtils.FixPriceValue(CGST28); // InvoiceInfo.Items28SGST = TrUtils.FixPriceValue(SGST28); // InvoiceInfo.TotalCGST = TrUtils.FixPriceValue(CGST18+CGST28); // InvoiceInfo.TotalSGST = TrUtils.FixPriceValue(SGST18+SGST28); // InvoiceInfo.Items18GST = TrUtils.FixPriceValue(CGST18+SGST18); // InvoiceInfo.Items28GST = TrUtils.FixPriceValue(CGST28+SGST28); InvoiceInfo.GSTAmount = InvoiceInfo.ItemsCGST + InvoiceInfo.ItemsSGST + InvoiceInfo.ItemsIGST; InvoiceInfo.TotalAmount = InvoiceInfo.GSTAmount + InvoiceInfo.ItemsNetAmt; InvoiceInfo.OpsGSTAmount = InvoiceInfo.OpsCGST + InvoiceInfo.OpsSGST + InvoiceInfo.OpsIGST; InvoiceInfo.TotalOpsAmount = InvoiceInfo.OpsGSTAmount + InvoiceInfo.OpsNetAmt; }); return MainData; } static GetWOTypeName(Type: any, WOTypes: any) { let Index: any = WOTypes.findIndex((wotype: any) => { return Type === wotype._id; }); if (Index !== -1) { return WOTypes[Index].Name; } else { return ''; } } static setHeadingInCell() { // let MainHeadings: any[] = [ // { // text: 'GSTIN/UIN', // ColRange: 1, // bold: true, // ChildHeadings: [] // }, // { // text: 'Name', // ColRange: 1, // bold: true, // ChildHeadings: [] // }, // { // text: 'InvoiceInfo Details', // ColRange: 4, // bold: true, // ChildHeadings: [ // { text: 'No', ColRange: 1 }, // { text: 'Date', ColRange: 1 }, // { text: 'InvoiceInfo Total', ColRange: 1 } // ] // }, // { // text: 'Rate', // ColRange: 1, // bold: true, // ChildHeadings: [] // }, // { // text: 'Taxable Value', // ColRange: 1, // bold: true, // ChildHeadings: [] // }, // { // text: 'Amount', // ColRange: 3, // bold: true, // ChildHeadings: [ // { text: 'Central Tax', ColRange: 1 }, // { text: 'State Tax', ColRange: 1 }, // { text: 'IGST Tax', ColRange: 1 }, // ] // } // ] let MainHeadings: any[] = [ // { // text: 'SNo', // ColRange: 1, // bold: true, // ChildHeadings: [] // }, { text: 'Date', ColRange: 1, bold: true, ChildHeadings: [], }, { text: 'Invoice No', ColRange: 1, bold: true, ChildHeadings: [ // { text: 'No', ColRange: 1 }, // { text: 'Date', ColRange: 1 }, // { text: 'InvoiceInfo Total', ColRange: 1 } ], }, { text: 'RO No', ColRange: 1, bold: true, ChildHeadings: [], }, { text: 'RO Date', ColRange: 1, bold: true, ChildHeadings: [], }, { text: 'Customer', ColRange: 1, bold: true, ChildHeadings: [ // { text: 'Central Tax', ColRange: 1 }, // { text: 'State Tax', ColRange: 1 }, // { text: 'IGST Tax', ColRange: 1 }, ], }, { text: 'Phone', ColRange: 1, bold: true, ChildHeadings: [ // { text: 'Central Tax', ColRange: 1 }, // { text: 'State Tax', ColRange: 1 }, // { text: 'IGST Tax', ColRange: 1 }, ], }, { text: 'Chassis No', ColRange: 1, bold: true, ChildHeadings: [ // { text: 'Central Tax', ColRange: 1 }, // { text: 'State Tax', ColRange: 1 }, // { text: 'IGST Tax', ColRange: 1 }, ], }, { text: 'Vehicle', ColRange: 1, bold: true, ChildHeadings: [ // { text: 'Central Tax', ColRange: 1 }, // { text: 'State Tax', ColRange: 1 }, // { text: 'IGST Tax', ColRange: 1 }, ], }, // { // text: 'Color', // ColRange: 1, // bold: true, // ChildHeadings: [ // // { text: 'Central Tax', ColRange: 1 }, // // { text: 'State Tax', ColRange: 1 }, // // { text: 'IGST Tax', ColRange: 1 }, // ] // }, { text: 'Year Of Model', ColRange: 1, bold: true, ChildHeadings: [ // { text: 'Central Tax', ColRange: 1 }, // { text: 'State Tax', ColRange: 1 }, // { text: 'IGST Tax', ColRange: 1 }, ], }, { text: 'Reg. No', ColRange: 1, bold: true, ChildHeadings: [ // { text: 'Central Tax', ColRange: 1 }, // { text: 'State Tax', ColRange: 1 }, // { text: 'IGST Tax', ColRange: 1 }, ], }, { text: 'Sale Date', ColRange: 1, bold: true, ChildHeadings: [ // { text: 'Central Tax', ColRange: 1 }, // { text: 'State Tax', ColRange: 1 }, // { text: 'IGST Tax', ColRange: 1 }, ], }, // { // text: 'Supervisor', // ColRange: 1, // bold: true, // ChildHeadings: [ // // { text: 'Central Tax', ColRange: 1 }, // // { text: 'State Tax', ColRange: 1 }, // // { text: 'IGST Tax', ColRange: 1 }, // ] // }, { text: 'Technician', ColRange: 1, bold: true, ChildHeadings: [ // { text: 'Central Tax', ColRange: 1 }, // { text: 'State Tax', ColRange: 1 }, // { text: 'IGST Tax', ColRange: 1 }, ], }, { text: 'Service Advisor', ColRange: 1, bold: true, ChildHeadings: [ // { text: 'Central Tax', ColRange: 1 }, // { text: 'State Tax', ColRange: 1 }, // { text: 'IGST Tax', ColRange: 1 }, ], }, { text: 'Service Type', ColRange: 1, bold: true, ChildHeadings: [ // { text: 'Central Tax', ColRange: 1 }, // { text: 'State Tax', ColRange: 1 }, // { text: 'IGST Tax', ColRange: 1 }, ], }, { text: 'Meter Reading', ColRange: 1, bold: true, ChildHeadings: [ // { text: 'Central Tax', ColRange: 1 }, // { text: 'State Tax', ColRange: 1 }, // { text: 'IGST Tax', ColRange: 1 }, ], }, { text: 'Quantity', ColRange: 1, bold: true, ChildHeadings: [ // { text: 'Central Tax', ColRange: 1 }, // { text: 'State Tax', ColRange: 1 }, // { text: 'IGST Tax', ColRange: 1 }, ], }, // { // text: '18% Spares Amount before Tax', // ColRange: 1, // bold: true, // ChildHeadings: [ // // { text: 'Central Tax', ColRange: 1 }, // // { text: 'State Tax', ColRange: 1 }, // // { text: 'IGST Tax', ColRange: 1 }, // ], // }, // { // text: '28% Spares Amount before Tax', // ColRange: 1, // bold: true, // ChildHeadings: [ // // { text: 'Central Tax', ColRange: 1 }, // // { text: 'State Tax', ColRange: 1 }, // // { text: 'IGST Tax', ColRange: 1 }, // ], // }, { text: 'Spares Amount', ColRange: 1, bold: true, ChildHeadings: [ // { text: 'Central Tax', ColRange: 1 }, // { text: 'State Tax', ColRange: 1 }, // { text: 'IGST Tax', ColRange: 1 }, ], }, { text: 'Spares Discount', ColRange: 1, bold: true, ChildHeadings: [ // { text: 'Central Tax', ColRange: 1 }, // { text: 'State Tax', ColRange: 1 }, // { text: 'IGST Tax', ColRange: 1 }, ], }, { text: 'Spares After Discount', ColRange: 1, bold: true, ChildHeadings: [ // { text: 'Central Tax', ColRange: 1 }, // { text: 'State Tax', ColRange: 1 }, // { text: 'IGST Tax', ColRange: 1 }, ], }, // { // text: '18% CGST', // ColRange: 1, // bold: true, // ChildHeadings: [ // // { text: 'Central Tax', ColRange: 1 }, // // { text: 'State Tax', ColRange: 1 }, // // { text: 'IGST Tax', ColRange: 1 }, // ], // }, // { // text: '18% SGST', // ColRange: 1, // bold: true, // ChildHeadings: [ // // { text: 'Central Tax', ColRange: 1 }, // // { text: 'State Tax', ColRange: 1 }, // // { text: 'IGST Tax', ColRange: 1 }, // ], // }, // { // text: '28% CGST', // ColRange: 1, // bold: true, // ChildHeadings: [ // // { text: 'Central Tax', ColRange: 1 }, // // { text: 'State Tax', ColRange: 1 }, // // { text: 'IGST Tax', ColRange: 1 }, // ], // }, // { // text: '28% SGST', // ColRange: 1, // bold: true, // ChildHeadings: [ // // { text: 'Central Tax', ColRange: 1 }, // // { text: 'State Tax', ColRange: 1 }, // // { text: 'IGST Tax', ColRange: 1 }, // ], // }, // { // text: 'Total CGST', // ColRange: 1, // bold: true, // ChildHeadings: [ // // { text: 'Central Tax', ColRange: 1 }, // // { text: 'State Tax', ColRange: 1 }, // // { text: 'IGST Tax', ColRange: 1 }, // ], // }, // { // text: 'Total SGST', // ColRange: 1, // bold: true, // ChildHeadings: [ // // { text: 'Central Tax', ColRange: 1 }, // // { text: 'State Tax', ColRange: 1 }, // // { text: 'IGST Tax', ColRange: 1 }, // ], // }, // { // text: '18% Spares Amount after Tax', // ColRange: 1, // bold: true, // ChildHeadings: [ // // { text: 'Central Tax', ColRange: 1 }, // // { text: 'State Tax', ColRange: 1 }, // // { text: 'IGST Tax', ColRange: 1 }, // ], // }, // { // text: '28% Spares Amount after Tax', // ColRange: 1, // bold: true, // ChildHeadings: [ // // { text: 'Central Tax', ColRange: 1 }, // // { text: 'State Tax', ColRange: 1 }, // // { text: 'IGST Tax', ColRange: 1 }, // ], // }, { text: 'CGST', ColRange: 1, bold: true, ChildHeadings: [ // { text: 'Central Tax', ColRange: 1 }, // { text: 'State Tax', ColRange: 1 }, // { text: 'IGST Tax', ColRange: 1 }, ], }, { text: 'SGST', ColRange: 1, bold: true, ChildHeadings: [ // { text: 'Central Tax', ColRange: 1 }, // { text: 'State Tax', ColRange: 1 }, // { text: 'IGST Tax', ColRange: 1 }, ], }, { text: 'IGST', ColRange: 1, bold: true, ChildHeadings: [ // { text: 'Central Tax', ColRange: 1 }, // { text: 'State Tax', ColRange: 1 }, // { text: 'IGST Tax', ColRange: 1 }, ], }, // { // text: 'CESS', // ColRange: 1, // bold: true, // ChildHeadings: [ // // { text: 'Central Tax', ColRange: 1 }, // // { text: 'State Tax', ColRange: 1 }, // // { text: 'IGST Tax', ColRange: 1 }, // ] // }, { text: 'GST Amount', ColRange: 1, bold: true, ChildHeadings: [ // { text: 'Central Tax', ColRange: 1 }, // { text: 'State Tax', ColRange: 1 }, // { text: 'IGST Tax', ColRange: 1 }, ], }, { text: 'Total Spares Amount', ColRange: 1, bold: true, ChildHeadings: [ // { text: 'Central Tax', ColRange: 1 }, // { text: 'State Tax', ColRange: 1 }, // { text: 'IGST Tax', ColRange: 1 }, ], }, { text: 'Labor Amount', ColRange: 1, bold: true, ChildHeadings: [ // { text: 'Central Tax', ColRange: 1 }, // { text: 'State Tax', ColRange: 1 }, // { text: 'IGST Tax', ColRange: 1 }, ], }, { text: 'Labor Discount', ColRange: 1, bold: true, ChildHeadings: [ // { text: 'Central Tax', ColRange: 1 }, // { text: 'State Tax', ColRange: 1 }, // { text: 'IGST Tax', ColRange: 1 }, ], }, { text: 'Labor After Discount', ColRange: 1, bold: true, ChildHeadings: [ // { text: 'Central Tax', ColRange: 1 }, // { text: 'State Tax', ColRange: 1 }, // { text: 'IGST Tax', ColRange: 1 }, ], }, { text: 'Service CGST', ColRange: 1, bold: true, ChildHeadings: [ // { text: 'Central Tax', ColRange: 1 }, // { text: 'State Tax', ColRange: 1 }, // { text: 'IGST Tax', ColRange: 1 }, ], }, { text: 'Service SGST', ColRange: 1, bold: true, ChildHeadings: [ // { text: 'Central Tax', ColRange: 1 }, // { text: 'State Tax', ColRange: 1 }, // { text: 'IGST Tax', ColRange: 1 }, ], }, { text: 'Service IGST', ColRange: 1, bold: true, ChildHeadings: [ // { text: 'Central Tax', ColRange: 1 }, // { text: 'State Tax', ColRange: 1 }, // { text: 'IGST Tax', ColRange: 1 }, ], }, // { // text: 'Service CESS', // ColRange: 1, // bold: true, // ChildHeadings: [ // // { text: 'Central Tax', ColRange: 1 }, // // { text: 'State Tax', ColRange: 1 }, // // { text: 'IGST Tax', ColRange: 1 }, // ] // }, { text: 'Service GST Amount', ColRange: 1, bold: true, ChildHeadings: [ // { text: 'Central Tax', ColRange: 1 }, // { text: 'State Tax', ColRange: 1 }, // { text: 'IGST Tax', ColRange: 1 }, ], }, { text: 'Total Labor Amount', ColRange: 1, bold: true, ChildHeadings: [ // { text: 'Central Tax', ColRange: 1 }, // { text: 'State Tax', ColRange: 1 }, // { text: 'IGST Tax', ColRange: 1 }, ], }, // { // text: 'Bill Amount', // ColRange: 1, // bold: true, // ChildHeadings: [ // // { text: 'Central Tax', ColRange: 1 }, // // { text: 'State Tax', ColRange: 1 }, // // { text: 'IGST Tax', ColRange: 1 }, // ] // }, { // text: 'Discount Amount', // ColRange: 1, // bold: true, // ChildHeadings: [ // // { text: 'Central Tax', ColRange: 1 }, // // { text: 'State Tax', ColRange: 1 }, // // { text: 'IGST Tax', ColRange: 1 }, // ] // }, // { // text: 'Total Bill Amount', // ColRange: 1, // bold: true, // ChildHeadings: [ // // { text: 'Central Tax', ColRange: 1 }, // // { text: 'State Tax', ColRange: 1 }, // // { text: 'IGST Tax', ColRange: 1 }, // ] // }, // { // text: 'Insurance Amount', // ColRange: 1, // bold: true, // ChildHeadings: [ // // { text: 'Central Tax', ColRange: 1 }, // // { text: 'State Tax', ColRange: 1 }, // // { text: 'IGST Tax', ColRange: 1 }, // ] // }, { // text: 'Charges', // ColRange: 1, // bold: true, // ChildHeadings: [ // // { text: 'Central Tax', ColRange: 1 }, // // { text: 'State Tax', ColRange: 1 }, // // { text: 'IGST Tax', ColRange: 1 }, // ] // }, { // text: 'Deductions', // ColRange: 1, // bold: true, // ChildHeadings: [ // // { text: 'Central Tax', ColRange: 1 }, // // { text: 'State Tax', ColRange: 1 }, // // { text: 'IGST Tax', ColRange: 1 }, // ] // }, { // text: 'Round Off Amount', // ColRange: 1, // bold: true, // ChildHeadings: [ // // { text: 'Central Tax', ColRange: 1 }, // // { text: 'State Tax', ColRange: 1 }, // // { text: 'IGST Tax', ColRange: 1 }, // ] // }, { text: 'Total Value', ColRange: 1, bold: true, ChildHeadings: [ // { text: 'Central Tax', ColRange: 1 }, // { text: 'State Tax', ColRange: 1 }, // { text: 'IGST Tax', ColRange: 1 }, ], }, ]; let MainColStart: any = 0; MainHeadings.forEach((MainHeader: any) => { this.SetDataInCell(MainHeader.text, MainColStart, this.Row); this.MergeArray.push({ s: { r: this.Row, c: MainColStart }, e: { r: this.Row, c: MainColStart + MainHeader.ColRange - 1 }, }); MainColStart += MainHeader.ColRange; }); this.Row += 2; } static setInvoiceDetailsInCell(MainData: any, DecimalsNumber: number) { MainData.forEach((InvoiceList: any) => { this.SetInvoiceDataInExcel(InvoiceList, DecimalsNumber); }); } static SetInvoiceDataInExcel(InvoiceInfo: any, DecimalsNumber: number) { InvoiceInfo.CrDate = this.ConvertDateToReadableFormat(InvoiceInfo.CrDate); InvoiceInfo.WCrDate = this.ConvertDateToReadableFormat(InvoiceInfo.WCrDate); InvoiceInfo.ProdDDate = this.ConvertDateToReadableFormat(InvoiceInfo.ProdDDate); let InvoiceData: any = [ { text: InvoiceInfo.CrDate, ColRange: 1, IsString: true }, { text: InvoiceInfo.Code, ColRange: 1, IsString: true }, { text: InvoiceInfo.WCrDate, ColRange: 1, IsString: true }, { text: InvoiceInfo.WCode, ColRange: 1, IsString: true }, { text: InvoiceInfo.CustName, ColRange: 1, IsString: true }, { text: InvoiceInfo.CustPh, ColRange: 1, IsString: true }, { text: InvoiceInfo.VIN, ColRange: 1, IsString: false }, { text: InvoiceInfo.Model, ColRange: 1, IsString: false }, { text: InvoiceInfo.Year, ColRange: 1, IsString: false }, { text: InvoiceInfo.RegNo, ColRange: 1, IsString: false }, { text: InvoiceInfo.ProdDDate, ColRange: 1, IsString: false }, { text: InvoiceInfo.TeNa, ColRange: 1, IsString: false }, { text: InvoiceInfo.Name, ColRange: 1, IsString: false }, { text: InvoiceInfo.TypeName, ColRange: 1, IsString: false }, { text: InvoiceInfo.MOut, ColRange: 1, IsString: false }, { text: InvoiceInfo.ItemsQty, ColRange: 1, IsString: false }, // { text: InvoiceInfo.Total18perc, ColRange: 1, IsString: false }, // { text: InvoiceInfo.Total28perc, ColRange: 1, IsString: false }, { text: InvoiceInfo.ItemsUnAmt, ColRange: 1, IsString: false }, { text: InvoiceInfo.ItemsDisc, ColRange: 1, IsString: false }, { text: InvoiceInfo.ItemsNetAmt, ColRange: 1, IsString: false }, // { text: InvoiceInfo.Items18CGST, ColRange: 1, IsString: false }, // { text: InvoiceInfo.Items18SGST, ColRange: 1, IsString: false }, // { text: InvoiceInfo.Items28CGST, ColRange: 1, IsString: false }, // { text: InvoiceInfo.Items28SGST, ColRange: 1, IsString: false }, // { text: InvoiceInfo.TotalCGST, ColRange: 1, IsString: false }, // { text: InvoiceInfo.TotalSGST, ColRange: 1, IsString: false }, // { text: InvoiceInfo.Total18perctax, ColRange: 1, IsString: false }, // { text: InvoiceInfo.Total28perctax, ColRange: 1, IsString: false }, { text: InvoiceInfo.ItemsCGST, ColRange: 1, IsString: false }, { text: InvoiceInfo.ItemsSGST, ColRange: 1, IsString: false }, { text: InvoiceInfo.ItemsIGST, ColRange: 1, IsString: false }, { text: InvoiceInfo.GSTAmount, ColRange: 1, IsString: false }, { text: InvoiceInfo.TotalAmount, ColRange: 1, IsString: false }, { text: InvoiceInfo.OpsPr, ColRange: 1, IsString: false }, { text: InvoiceInfo.OpsDisc, ColRange: 1, IsString: false }, { text: InvoiceInfo.OpsNetAmt, ColRange: 1, IsString: false }, { text: InvoiceInfo.OpsCGST, ColRange: 1, IsString: false }, { text: InvoiceInfo.OpsSGST, ColRange: 1, IsString: false }, { text: InvoiceInfo.OpsIGST, ColRange: 1, IsString: false }, { text: InvoiceInfo.OpsGSTAmount, ColRange: 1, IsString: false }, { text: InvoiceInfo.TotalOpsAmount, ColRange: 1, IsString: false }, // { text: InvoiceInfo.SubTotal, ColRange: 1, IsString: false }, { text: InvoiceInfo.Total, ColRange: 1, IsString: false }, ]; let ColStart: any = 0; InvoiceData.forEach((InvData: any) => { InvData.text = this.ConvertToString(InvData.text, InvData.IsString, DecimalsNumber); this.SetDataInCell(InvData.text, ColStart, this.Row); this.MergeArray.push({ s: { r: this.Row, c: ColStart }, e: { r: this.Row, c: ColStart + InvData.ColRange - 1 }, }); ColStart += InvData.ColRange; }); this.Row += 1; } static ConvertToString(Text: any, IsString: any, DecimalsNumber: number) { if (IsString) { if (Text == null) { Text = ''; } } else { if (Text == null) { Text = 0; } } if (typeof Text === 'number') { return Number(TrUtils.FixedTo(Text, DecimalsNumber)); } else { return Text; } } static SetDataInCell(Data: any, ColRange: number, RowNum: any) { var cell = { v: Data }; var cell_ref = XLSX.utils.encode_cell({ c: ColRange, r: RowNum }); if (this.range.e.c < ColRange) { this.range.e.c = ColRange; } if (this.range.e.r < RowNum) { this.range.e.r = RowNum; } cell = this.getcelltype(cell); this.ws[cell_ref] = cell; } static getcelltype(cell: any) { if (typeof cell.v === 'number') cell.t = 'n'; else if (typeof cell.v === 'boolean') cell.t = 'b'; else cell.t = 's'; return cell; } static ConvertDateToReadableFormat(DateObject: any) { if (!TrUtils.IsEmpty(DateObject)) { let date: any = new Date(DateObject); let Month: any; let Day: any; let MonthName = new Array(); MonthName[0] = 'Jan'; MonthName[1] = 'Feb'; MonthName[2] = 'Mar'; MonthName[3] = 'Apr'; MonthName[4] = 'May'; MonthName[5] = 'Jun'; MonthName[6] = 'Jul'; MonthName[7] = 'Aug'; MonthName[8] = 'Sept'; MonthName[9] = 'Oct'; MonthName[10] = 'Nov'; MonthName[11] = 'Dec'; Month = MonthName[date.getMonth()]; if (date.getDate() < 10) { Day = '0' + date.getDate(); } else { Day = date.getDate(); } date = Day + '-' + Month + '-' + date.getFullYear(); return date; } else { return null; } } }