Grid - Export to PDF with custom Columns does not format dateTime

Hello Syncfusion-Team,


In my grid I want to export the Grid as PDF. I have two columns with the type dateTime and have managed the formatting setting the format property on the column itself in the html like this:

    [format]="{ type: 'dateTime', format: 'dd.MM.yyyy - HH:mm' }"


Because I only want to display columns in my PDF export which contain the field property, I am iterating over the columns and am only exporting those specific columns. My PDF export function looks like this:

  requestExport(type: 'PDF' | 'XLSX') {
    let exportColumns = new Array<any>();

    this.grid.getColumns().forEach((col) => {
      if (col.field) {
        exportColumns.push(col);
      }
    });

    if (type === 'PDF') {
      this.grid.pdfExport({
        columns: exportColumns,
        fileName: `${this.exportFileName} - ${Utility.currentDateTime}.pdf`,
        pageOrientation: 'Landscape',
        allowHorizontalOverflow: false,
      });
    } else if (type === 'XLSX') {
      this.grid.excelExport({
        columns: exportColumns,
        fileName: `${this.exportFileName} - ${Utility.currentDateTime}.xlsx`,
      });
    }
  }


The problem is that the exported PDF does not format the dateTime format properly:


However, when I am removing the columns property in the pdfExportSettings the dateTime format is correct:


Is it a problem of the grid itself or am I doing something wrong here?


Thanks, Peter


1 Reply

RS Rajapandiyan Settu Syncfusion Team June 29, 2022 05:48 PM UTC

Hi Peter,


Thanks for contacting Syncfusion support.


We are unable to reproduce the reported problems at our end. Formatting is properly applied when we export the Grid with custom columns. Find the below sample for your reference.


Sample: https://stackblitz.com/edit/angular-45jbcb?file=app.component.html,app.component.ts


Kindly share the below details to replicate the issues at our end.


  1. Share the complete code files you have used and package.json file.
  2. Did you customize the value in the pdfQueryCellInfo event?
  3. If possible, share the issue reproducible sample or try to make the issue in the given sample which will be very helpful to resolve this earlier.


Regards,

Rajapandiyan S


Loader.
Up arrow icon