igniteui-angular icon indicating copy to clipboard operation
igniteui-angular copied to clipboard

Format columns in excel export

Open Eralmidia opened this issue 7 years ago • 2 comments

Question

Is it possible to apply a formatter or similar to columns in the excel export? For instance in the export below, I would like to apply different colors for the Status column, based on Passed or Failed values, and also the date/time column has a rather unfortunate formatting (and is in addition formatted as General and not Date by Excel, even though the exported column did contain dates)

image

  • igniteui-angular version: 7.3.2
  • browser: Chrome

Eralmidia avatar Jun 05 '19 07:06 Eralmidia

@Eralmidia, currently we support exporting data as formatted in the grid. So in order to have different data formatter you may apply some custom formatter on a date column, and the exporter would automatically pick it up.

<igx-column field="OrderDate" width="200px" [dataType]="'date'" [hasSummary]="false" [sortable]="true" [formatter]="dateFormat">

...

dateFormat(val: Date) {
        const options = { weekday: 'short', year: 'numeric', month: 'long', day: 'numeric' };
        return new Intl.DateTimeFormat('us', options).format(val);
    }

As for applying formatting in the actual exported worksheet, you will need to use the excel library instead of this simple exporter feature.

astaev avatar Jun 12 '19 14:06 astaev

@astaev Thanks for the clarifications 👍

Eralmidia avatar Jun 12 '19 18:06 Eralmidia