import * as XLSX from 'xlsx'; import { TrUtils } from '../../utils/tr-utils'; export class GSTROXlsxFileService { 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 MainHeadings: any[] = []; static GetGSTROExcelData(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 = 'GST RO'; this.wb.Sheets = {}; this.wb.Props = {}; this.wb.SSF = {}; this.wb.SheetNames = []; MainData = this.GetTotals(MainData, WOTypes); this.setHeadingInCell(MainData); this.setInvoiceDetailsInCell(MainData, EntitySettings); this.ws['!ref'] = XLSX.utils.encode_range(this.range); this.ws['!merges'] = this.MergeArray; this.ws["!cols"] = [{ wch: 15 }, { wch: 15 }, { wch: 15 }, { wch: 50 }, { wch: 15 }, { wch: 15 }, { wch: 15 }, { wch: 15 }, { wch: 15 }, { wch: 15 }, { wch: 15 }, { wch: 15 }, { wch: 15 }, { wch: 15 }, { wch: 15 }, { wch: 15 }, { wch: 15 }, { wch: 15 }, { wch: 15 }, { wch: 15 } , { wch: 15 }, { wch: 15 }, { wch: 15 }, { wch: 15 }, { wch: 15 }, { wch: 15 }, { wch: 15 }, { wch: 15 }, { wch: 15 }, { wch: 15 }, { wch: 15 }, { wch: 15 }, { wch: 15 }, { wch: 15 }, { wch: 15 }, { wch: 15 }, { wch: 15 }, { wch: 15 }, { wch: 15 }, { wch: 15 }, { wch: 15 }, { wch: 15 }, { wch: 15 }, { wch: 15 } , { wch: 15 }, { wch: 15 }, { wch: 15 }, { wch: 15 }]; 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.WOType, WOTypes); } InvoiceInfo.Invoices.forEach((invoice:any)=>{ let CGSTAmt:any=0; let SGSTAmt:any=0; let IGSTAmt:any=0; invoice.ItemsArray.forEach((item:any)=>{ CGSTAmt=CGSTAmt+item.CGST; SGSTAmt=SGSTAmt+item.SGST; IGSTAmt=IGSTAmt+item.IGST; }); invoice.LaborArray.forEach((item:any)=>{ CGSTAmt=CGSTAmt+item.CGST; SGSTAmt=SGSTAmt+item.SGST; IGSTAmt=IGSTAmt+item.IGST; }); invoice.CGSTAmt=CGSTAmt; invoice.SGSTAmt=SGSTAmt; invoice.IGSTAmt=IGSTAmt; }); // 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.Parts) && InvoiceInfo.Parts.length !==0){ // InvoiceInfo.Parts.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(MainData: any) { this.MainHeadings = [ { text: 'SNo', ColRange: 1, field: 'SNo', bold: true, ChildHeadings: [] }, { text: 'Invoice No', ColRange: 1, field: 'Code', bold: true, ChildHeadings: [ // { text: 'No', ColRange: 1 }, // { text: 'Date', ColRange: 1 }, // { text: 'InvoiceInfo Total', ColRange: 1 } ], }, { text: 'Invoice Date', ColRange: 1, field: 'CrDate', bold: true, ChildHeadings: [], }, { text: 'Customer', ColRange: 1, field: 'Name', bold: true, ChildHeadings: [ // { text: 'Central Tax', ColRange: 1 }, // { text: 'State Tax', ColRange: 1 }, // { text: 'IGST Tax', ColRange: 1 }, ], }, { text: 'GSTIN', ColRange: 1, field: 'GSTIN', bold: true, ChildHeadings: [ // { text: 'Central Tax', ColRange: 1 }, // { text: 'State Tax', ColRange: 1 }, // { text: 'IGST Tax', ColRange: 1 }, ], }, { text: 'Total Amt', ColRange: 1, field: 'Total', bold: true, ChildHeadings: [], }, { text: 'Total Amount excluding GST', ColRange: 1, field: 'SubTotal', bold: true, ChildHeadings: [], }, { text: 'Parts Taxable Amt', ColRange: 1, field: 'Taxable', bold: true, ChildHeadings: [], }, ]; MainData.forEach((InvoiceList: any) => { InvoiceList.Invoices.forEach((invoice: any) => { invoice.ItemsArray.forEach((item: any) => { if (item.Rate === 0.25) { let Index: any = this.MainHeadings.findIndex((Header: any) => { return Header.Rate === 'I0.25' }); if (Index === -1) { this.MainHeadings.push({ text: 'Taxable value spare sales @ 0.25%', ColRange: 1, Rate: 'I0.25', field: 'Taxable0.25', bold: true, ChildHeadings: [], }); this.MainHeadings.push({ text: 'Parts 0.25%', ColRange: 1, Rate: 'I0.25', field: 0.25, Parts: 'Parts', bold: true, ChildHeadings: [], }); this.MainHeadings.push({ text: 'Parts CGST 0.25%', ColRange: 1, Rate: 'I0.25', field: 'CGST', bold: true, ChildHeadings: [], }); this.MainHeadings.push({ text: 'Parts SGST 0.25%', ColRange: 1, Rate: 'I0.25', field: 'SGST', bold: true, ChildHeadings: [], }); this.MainHeadings.push({ text: 'Parts IGST 0.25%', ColRange: 1, Rate: 'I0.25', field: 'IGST', bold: true, ChildHeadings: [], }); } } else if (item.Rate === 3) { let Index: any = this.MainHeadings.findIndex((Header: any) => { return Header.Rate === 'I3' }); if (Index === -1) { this.MainHeadings.push({ text: 'Taxable value spare sales @ 3%', ColRange: 1, Rate: 'I3', field: 'Taxable3', bold: true, ChildHeadings: [], }); this.MainHeadings.push({ text: 'Parts 3%', ColRange: 1, Rate: 'I3', field: 3, Parts: 'Parts', bold: true, ChildHeadings: [], }); this.MainHeadings.push({ text: 'Parts CGST 3%', ColRange: 1, Rate: 'I3', bold: true, ChildHeadings: [], }); this.MainHeadings.push({ text: 'Parts SGST 3%', ColRange: 1, Rate: 'I3', bold: true, ChildHeadings: [], }); this.MainHeadings.push({ text: 'Parts IGST 3%', ColRange: 1, Rate: 'I3', bold: true, ChildHeadings: [], }); } } else if (item.Rate === 5) { let Index: any = this.MainHeadings.findIndex((Header: any) => { return Header.Rate === 'I5' }); if (Index === -1) { this.MainHeadings.push({ text: 'Taxable value spare sales @ 5%', ColRange: 1, Rate: 'I5', field: 'Taxable5', bold: true, ChildHeadings: [], }); this.MainHeadings.push({ text: 'Parts 5%', ColRange: 1, Rate: 'I5', field: 5, Parts: 'Parts', bold: true, ChildHeadings: [], }); this.MainHeadings.push({ text: 'Parts CGST 5%', ColRange: 1, Rate: 'I5', bold: true, ChildHeadings: [], }); this.MainHeadings.push({ text: 'Parts SGST 5%', ColRange: 1, Rate: 'I5', bold: true, ChildHeadings: [], }); this.MainHeadings.push({ text: 'Parts IGST 5%', ColRange: 1, Rate: 'I5', bold: true, ChildHeadings: [], }); } } else if (item.Rate === 12) { let Index: any = this.MainHeadings.findIndex((Header: any) => { return Header.Rate === 'I12' }); if (Index === -1) { this.MainHeadings.push({ text: 'Taxable value spare sales @ 12%', ColRange: 1, Rate: 'I12', field: 'Taxable12', bold: true, ChildHeadings: [], }); this.MainHeadings.push({ text: 'Parts 12%', ColRange: 1, Rate: 'I12', field: 12, Parts: 'Parts', bold: true, ChildHeadings: [], }); this.MainHeadings.push({ text: 'Parts CGST 12%', ColRange: 1, Rate: 'I12', bold: true, ChildHeadings: [], }); this.MainHeadings.push({ text: 'Parts SGST 12%', ColRange: 1, Rate: 'I12', bold: true, ChildHeadings: [], }); this.MainHeadings.push({ text: 'Parts IGST 12%', ColRange: 1, Rate: 'I12', bold: true, ChildHeadings: [], }); } } else if (item.Rate === 18) { let Index: any = this.MainHeadings.findIndex((Header: any) => { return Header.Rate === 'I18' }); if (Index === -1) { this.MainHeadings.push({ text: 'Taxable value spare sales @ 18%', ColRange: 1, Rate: 'I18', field: 'Taxable18', bold: true, ChildHeadings: [], }); this.MainHeadings.push({ text: 'Parts 18%', ColRange: 1, Rate: 'I18', field: 18, Parts: 'Parts', bold: true, ChildHeadings: [], }); this.MainHeadings.push({ text: 'Parts CGST 18%', ColRange: 1, Rate: 'I18', bold: true, ChildHeadings: [], }); this.MainHeadings.push({ text: 'Parts SGST 18%', ColRange: 1, Rate: 'I18', bold: true, ChildHeadings: [], }); this.MainHeadings.push({ text: 'Parts IGST 18%', ColRange: 1, Rate: 'I18', bold: true, ChildHeadings: [], }); } } else if (item.Rate === 28) { let Index: any = this.MainHeadings.findIndex((Header: any) => { return Header.Rate === 'I28' }); if (Index === -1) { this.MainHeadings.push({ text: 'Taxable value spare sales @ 28%', ColRange: 1, Rate: 'I28', field: 'Taxable28', bold: true, ChildHeadings: [], }); this.MainHeadings.push({ text: 'Parts 28%', ColRange: 1, Rate: 'I28', bold: true, field: 28, Parts: 'Parts', ChildHeadings: [], }); this.MainHeadings.push({ text: 'Parts CGST 28%', ColRange: 1, Rate: 'I28', bold: true, ChildHeadings: [], }); this.MainHeadings.push({ text: 'Parts SGST 28%', ColRange: 1, Rate: 'I28', field: 28, bold: true, ChildHeadings: [], }); this.MainHeadings.push({ text: 'Parts IGST 28%', ColRange: 1, Rate: 'I28', field: 28, bold: true, ChildHeadings: [], }); } } }); }); }); this.MainHeadings.push({ text: 'Labor Taxable Amt', ColRange: 1, field: 'LaborTaxable', bold: true, ChildHeadings: [], }); MainData.forEach((InvoiceList: any) => { InvoiceList.Invoices.forEach((invoice: any) => { invoice.LaborArray.forEach((labor: any) => { if (labor.Rate === 0.25) { let Index: any = this.MainHeadings.findIndex((Header: any) => { return Header.Rate === 'L0.25' }); if (Index === -1) { this.MainHeadings.push({ text: 'Labor 0.25%', ColRange: 1, bold: true, field: 0.25, Labor: 'Labor', Rate: 'L0.25', ChildHeadings: [], }); this.MainHeadings.push({ text: 'Labor CGST 0.25%', ColRange: 1, Rate: 'L0.25', bold: true, ChildHeadings: [], }); this.MainHeadings.push({ text: 'Labor SGST 0.25%', ColRange: 1, Rate: 'L0.25', bold: true, ChildHeadings: [], }); this.MainHeadings.push({ text: 'Labor IGST 0.25%', ColRange: 1, Rate: 'L0.25', bold: true, ChildHeadings: [], }); } } else if (labor.Rate === 3) { let Index: any = this.MainHeadings.findIndex((Header: any) => { return Header.Rate === 'L3' }); if (Index === -1) { this.MainHeadings.push({ text: 'Labor 3%', ColRange: 1, Rate: 'L3', field: 3, Labor: 'Labor', bold: true, ChildHeadings: [], }); this.MainHeadings.push({ text: 'Labor CGST 3%', ColRange: 1, Rate: 'L3', bold: true, ChildHeadings: [], }); this.MainHeadings.push({ text: 'Labor SGST 3%', ColRange: 1, Rate: 'L3', bold: true, ChildHeadings: [], }); this.MainHeadings.push({ text: 'Labor IGST 3%', ColRange: 1, Rate: 'L3', bold: true, ChildHeadings: [], }); } } else if (labor.Rate === 5) { let Index: any = this.MainHeadings.findIndex((Header: any) => { return Header.Rate === 'L5' }); if (Index === -1) { this.MainHeadings.push({ text: 'Labor 5%', ColRange: 1, bold: true, field: 5, Labor: 'Labor', Rate: 'L5', ChildHeadings: [], }); this.MainHeadings.push({ text: 'Labor CGST 5%', ColRange: 1, Rate: 'L5', bold: true, ChildHeadings: [], }); this.MainHeadings.push({ text: 'Labor SGST 5%', ColRange: 1, Rate: 'L5', bold: true, ChildHeadings: [], }); this.MainHeadings.push({ text: 'Labor IGST 5%', ColRange: 1, Rate: 'L5', bold: true, ChildHeadings: [], }); } } else if (labor.Rate === 12) { let Index: any = this.MainHeadings.findIndex((Header: any) => { return Header.Rate === 'L12' }); if (Index === -1) { this.MainHeadings.push({ text: 'Labor 12%', ColRange: 1, Rate: 'L12', field: 12, Labor: 'Labor', bold: true, ChildHeadings: [], }); this.MainHeadings.push({ text: 'Labor CGST 12%', ColRange: 1, Rate: 'L12', bold: true, ChildHeadings: [], }); this.MainHeadings.push({ text: 'Labor SGST 12%', ColRange: 1, Rate: 'L12', bold: true, ChildHeadings: [], }); this.MainHeadings.push({ text: 'Labor IGST 12%', ColRange: 1, Rate: 'L12', bold: true, ChildHeadings: [], }); } } else if (labor.Rate === 18) { let Index: any = this.MainHeadings.findIndex((Header: any) => { return Header.Rate === 'L18' }); if (Index === -1) { this.MainHeadings.push({ text: 'Labor 18%', ColRange: 1, Rate: 'L18', field: 18, Labor: 'Labor', bold: true, ChildHeadings: [], }); this.MainHeadings.push({ text: 'Labor CGST 18%', ColRange: 1, Rate: 'L18', bold: true, ChildHeadings: [], }); this.MainHeadings.push({ text: 'Labor SGST 18%', ColRange: 1, Rate: 'L18', bold: true, ChildHeadings: [], }); this.MainHeadings.push({ text: 'Labor IGST 18%', ColRange: 1, Rate: 'L18', bold: true, ChildHeadings: [], }); } } else if (labor.Rate === 28) { let Index: any = this.MainHeadings.findIndex((Header: any) => { return Header.Rate === 'L28' }); if (Index === -1) { this.MainHeadings.push({ text: 'Labor 28%', ColRange: 1, Rate: 'L28', field: 28, Labor: 'Labor', bold: true, ChildHeadings: [], }); this.MainHeadings.push({ text: 'Labor CGST 28%', ColRange: 1, Rate: 'L28', bold: true, ChildHeadings: [], }); this.MainHeadings.push({ text: 'Labor SGST 28%', ColRange: 1, Rate: 'L28', bold: true, ChildHeadings: [], }); this.MainHeadings.push({ text: 'Labor IGST 28%', ColRange: 1, Rate: 'L28', bold: true, ChildHeadings: [], }); } } }); }); }); this.MainHeadings.push({ text: 'Output CGST', ColRange: 1, field: 'CGSTAmt', bold: true, ChildHeadings: [], }); this.MainHeadings.push({ text: 'Output SGST', ColRange: 1, field: 'SGSTAmt', bold: true, ChildHeadings: [], }); this.MainHeadings.push({ text: 'Output IGST', ColRange: 1, field: 'IGSTAmt', bold: true, ChildHeadings: [], }); this.MainHeadings.push({ text: 'Round off', ColRange: 1, field: 'Round', bold: true, ChildHeadings: [], }); let MainColStart: any = 0; this.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) { let SNO: number = 0; MainData.forEach((InvoiceList: any) => { InvoiceList.Invoices.forEach((invoice: any, Index: any) => { SNO = SNO + 1; this.SetInvoiceDataInExcel(invoice, SNO, DecimalsNumber); }) }); } static SetInvoiceDataInExcel(InvoiceInfo: any, Index: any, DecimalsNumber:number) { // console.log(InvoiceInfo); InvoiceInfo.CrDate = this.ConvertDateToReadableFormat(InvoiceInfo.CrDate); let InvoiceData: any = []; this.MainHeadings.forEach((Header: any) => { if (Header.field === 'SNo') { InvoiceData.push({ text: Index, ColRange: 1, IsString: true }); } else if (Header.field === 'Code' || Header.field === 'CrDate' || Header.field === 'Name' || Header.field === 'GSTIN' || Header.field === 'Total' || Header.field === 'SubTotal' || Header.field === 'Round' || Header.field === 'CGSTAmt' || Header.field === 'SGSTAmt' || Header.field === 'IGSTAmt') { InvoiceData.push({ text: InvoiceInfo[Header.field], ColRange: 1, IsString: true }); } else if (Header.Parts === 'Parts') { let PIndex: any = InvoiceInfo.ItemsArray.findIndex((item: any) => { return item.Rate === Header.field; }); if (PIndex !== -1) { let TaxResult: number = InvoiceInfo.ItemsArray[PIndex].CGST + InvoiceInfo.ItemsArray[PIndex].SGST + InvoiceInfo.ItemsArray[PIndex].IGST; InvoiceData.push({ text: InvoiceInfo.ItemsArray[PIndex].Taxable, ColRange: 1, IsString: true }); InvoiceData.push({ text: TaxResult, ColRange: 1, IsString: true }); InvoiceData.push({ text: InvoiceInfo.ItemsArray[PIndex].CGST, ColRange: 1, IsString: true }); InvoiceData.push({ text: InvoiceInfo.ItemsArray[PIndex].SGST, ColRange: 1, IsString: true }); InvoiceData.push({ text: InvoiceInfo.ItemsArray[PIndex].IGST, ColRange: 1, IsString: true }); } else { InvoiceData.push({ text: '', ColRange: 1, IsString: true }); InvoiceData.push({ text: '', ColRange: 1, IsString: true }); InvoiceData.push({ text: '', ColRange: 1, IsString: true }); InvoiceData.push({ text: '', ColRange: 1, IsString: true }); InvoiceData.push({ text: '', ColRange: 1, IsString: true }); } } else if (Header.Labor === 'Labor') { let LIndex: any = InvoiceInfo.LaborArray.findIndex((labor: any) => { return labor.Rate === Header.field; }); if (LIndex !== -1) { let TaxResult: number = InvoiceInfo.LaborArray[LIndex].CGST + InvoiceInfo.LaborArray[LIndex].SGST + InvoiceInfo.LaborArray[LIndex].IGST; InvoiceData.push({ text: TaxResult, ColRange: 1, IsString: true }); InvoiceData.push({ text: InvoiceInfo.LaborArray[LIndex].CGST, ColRange: 1, IsString: true }); InvoiceData.push({ text: InvoiceInfo.LaborArray[LIndex].SGST, ColRange: 1, IsString: true }); InvoiceData.push({ text: InvoiceInfo.LaborArray[LIndex].IGST, ColRange: 1, IsString: true }); } else { InvoiceData.push({ text: '', ColRange: 1, IsString: true }); InvoiceData.push({ text: '', ColRange: 1, IsString: true }); InvoiceData.push({ text: '', ColRange: 1, IsString: true }); InvoiceData.push({ text: '', ColRange: 1, IsString: true }); } } else if(Header.field === 'LaborTaxable'){ let Taxable: number = 0; InvoiceInfo.LaborArray.forEach((item: any) => { Taxable = Taxable + item.Taxable; }); InvoiceData.push({ text: Taxable, ColRange: 1, IsString: true }); }else if(Header.field === 'Taxable'){ let Taxable: number = 0; InvoiceInfo.ItemsArray.forEach((item: any) => { Taxable = Taxable + item.Taxable; }); InvoiceData.push({ text: Taxable, ColRange: 1, IsString: true }); } }) 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; } } }