I'm using IgxExcelExporterService to export my columns and data to Excel. However, I'm facing issue whereby all my columns that contains the Datetime data type wasn't properly displayed in Excel unless I modified the column manually from Excel with custom formats. (Eg: d/m/yyyy h: mm).
I want all these columns to be able properly displayed and sort according to a datetime data type, on Export.
Modifed `igx-column` to have `dateTime` data type, adding `[pipeArgs]` to have predefined date format option. But those changes still wasn't reflect on exported Excel.
`igx-column`
dateTime
`[
pipeArgs]`
I've dug into the docs, another possible solution I could find is by manipulating rows and cells using Excel Library. However, since that I'm using `igx-columns` to create the data, is this the right thing to refer to? Perhaps there is a way to do this?
Thanks
Afif
Hello Afif,
After investigating this further, I determined that your requirement could be achieved by subscribing to the rowExporting event of the excelExporter service and formatting the date column as follows:
this.excelExportService.rowExporting.subscribe((args) => {
args.rowData.LaunchDate = this.datePipe.transform(
args.rowData.LaunchDate,
'yyyy-MM-dd'
);
});
Another suggestion would be to use the formatter option of igx-column instead of pipeArgs. By setting a formatter to the column, the exported date column is automatically formatted in the excel file:
<igx-column field="LaunchDate" header="Launch Date" [sortable]="true" [dataType]="'date'" [formatter]="dateFormat"></igx-column>
I have prepared a sample, demonstrating the described behavior. Please test it on your side and let me know if you need any further information regarding this matter.
Regards, Monika Kirkova, Infragistics