new CsvDownload($injector, gettextCatalog)
Service to generate and download a CSV file from tabular data.
Column headers are translated using angularGettext.Catalog
.
Parameters:
Name | Type | Description |
---|---|---|
$injector |
angular.$injector | Main injector. |
gettextCatalog |
angularGettext.Catalog | Gettext service. |
Methods
generateCsv(data, columnDefs)
Generate a CSV.
Parameters:
Name | Type | Description |
---|---|---|
data |
Array. | Entries/objects to include in the CSV. |
columnDefs |
Array. |
Column definitions. |
Returns:
string
The CSV file as string.
startDownload(data, columnDefs, fileName)
Generate a CSV and start a download with the generated file.
Parameters:
Name | Type | Description |
---|---|---|
data |
Array. | Entries/objects to include in the CSV. |
columnDefs |
Array. |
Column definitions. |
fileName |
string | The CSV file name, without the extension. |