asafdav / ng-csv

Simple directive that turns arrays and objects into downloadable CSV files
MIT License
573 stars 215 forks source link

How to add more than one header? #229

Open mkarrfan opened 6 years ago

mkarrfan commented 6 years ago

Please refer attachment.

2Headers.xlsx

dekhosla commented 5 years ago

Its easy HTML

button type="button" ng-csv="exportArray()" filename="Reports_CSV.csv" csv-main="headerFirstExport" csv-header="headerExport">export</button

Javascript

$scope.exportArray = function () {   
    return $scope.data;
}  $scope.headerFirstExport=['CSV-header 1 -   Column A','CSV-header 1- Column B','CSV-header 1 - Column C']; 
$scope.headerExport = ['CSV-header 2 -   Column A','CSV-header 2 - Column B','CSV-header 2 - Column C'];

Library for ng-csv is attached below

ng-csv.txt

anjalih28 commented 3 years ago

@dekhosla Hi I am trying to add two headers too. But csv-main does not seem to work for me.