0

html

 <p-dataTable [hidden]="loading" [rowStyleClass]="customRowClass" [value]="timePeriods" scrollable="true" scrollHeight="400px">
        <p-column field="StartDate" header="Begindatum" sortable="false">
            <template let-col let-timePeriod="rowData" pTemplate type="body">
                <span [class.missingPeriod]="!timePeriod.IsNext">{{timePeriod.StartDate | date: 'dd-MM yyyy'}}</span>
            </template>
        </p-column>
        <p-column field="EndDate" header="Einddatum" sortable="false">
            <template let-col let-timePeriod="rowData" pTemplate type="body">
                <span>{{timePeriod.EndDate | date: 'dd-MM yyyy'}}</span>
            </template>
        </p-column>
    </p-dataTable>
Vignesh
  • 2,378
  • 3
  • 25
  • 48

1 Answers1

0

PrimeNG

Right now there is not yet support for exporting a PrimeNG datatable to PDF.

This feature is on the roadmap though, you can see it here.

jsPDF

What you could do is downloading a div as a PDF using jsPDF. Have a look at this question on Stackoverflow for an implementation.

Brampage
  • 6,014
  • 4
  • 33
  • 47
  • jsPDF takes the screenshot and download the html in PDF format. – Vignesh Dec 12 '17 at 12:28
  • @Vignesh Yes, you will only have the data that is shown to the user. – Brampage Dec 12 '17 at 12:31
  • If i want to download a primeng datatable in csv format with expression values and pipes it's not loading in download data. – Vignesh Dec 12 '17 at 12:36
  • I'm not quite sure if I understand you correctly. In this example I managed to export all rows to a csv file (https://stackblitz.com/edit/angular-2u8ahh). – Brampage Dec 12 '17 at 12:52
  • For example i have formatted the EndDate in expression "{{timePeriod.EndDate | date: 'dd-MM yyyy'}}" and assigned to table. I want to download data in csv format with formatted Date. – Vignesh Dec 13 '17 at 04:30