Exporting data in CSV format

The data can be viewed in table format in online mode at any time. But, there is a need of data in an offline mode. Also in many cases, we need to take huge data reports from the website. PrimeNG DataTable can be exported in CSV format using the exportCSV() API method. Button components placed inside or outside of the table can trigger this method for downloading the data in the CSV format. The component with export API method call would be written as follows:

<p-dataTable #dt [value]="basicBrowsers" exportFilename="browsers"   
csvSeparator=";">
<p-header>
<div class="ui-helper-clearfix">
<button type="button" pButton icon="fa-file-o" iconPos="left"
label="CSV" (click)="dt.exportCSV()" style="float:left"></button>
</div>
</p-header>
<p-column field="engine" header="Engine"></p-column>
<p-column field="browser" header="Browser"></p-column>
<p-column field="platform" header="Platform"></p-column>
<p-column field="grade" header="Grade"></p-column>
</p-dataTable>

By default, exported CSV uses a comma (,) operator as a separator. But, this behavior can be changed using the csvSeparator property on a DataTable component.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.237.79