lhanscom / ngx-csv

Helper library for create CSV file in Angular 7
MIT License
4 stars 5 forks source link

Create additional headers #9

Closed saifuldhaka closed 4 years ago

saifuldhaka commented 5 years ago

in my angular6 project need some additional info like title, sub title1, sub title2, before headers. but not see any samples in the documents. here i attached how i wants my titles.

`

` Image link

CAspeling commented 5 years ago

Does the title part of the options help at all?

saifuldhaka commented 5 years ago

@CAspeling options title working but i need sub titles/descriptions/date range ets also as the demo i attached

CAspeling commented 5 years ago

@saifuldhaka You could make an array of objects, each object being a row you want to display. You'll have to set the options with headers as nothing.

saifuldhaka commented 5 years ago

@CAspeling thanks for reply, can provide me any example plz, here is my option

` var options = { decimalseparator: '.', showLabels: true, showTitle: true, title: 'Company Name', headers: ["Product Name", "Product Code", "Size", "UOM", "Opening Balance", "Incoming Stock", "Current Stock", "Total Usage", "Closing Balance"] };

var data = [

]

`

CAspeling commented 5 years ago

e.g.

let data = [
{ "example first row text" },
{ "example second row text" },
{ "example third row text" },
{"Product Name", "Product Code", "Size", "UOM", "Opening Balance", "Incoming Stock", "Current Stock", "Total Usage", "Closing Balance" },
{ "data1, "data2", "data3", ....ect }
];
saifuldhaka commented 5 years ago

@CAspeling thanks i got your points. here i share my full code.

` var options = { decimalseparator: '.', showLabels: true, showTitle: true, title: 'ABC Company ', headers: ["Product Name", "Product Code", "Size", "UOM", "Opening Balance", "Incoming Stock", "Current Stock", "Total Usage", "Closing Balance"] };

var data = [
  {
    name: "HA Latex",
    code: "-",
    size: "-",
    uom: "KGS",
    opening_balance: 20500,
    incoming_stock: 0,
    current_stock:  20500,
    total_usage: 5000,
    closing_balance: 15500
  },
  {
    name: "Latex 105",
    code: "-",
    size: "-",
    uom: "KGS",
    opening_balance: 20500,
    incoming_stock: 0,
    current_stock:  20500,
    total_usage: 5000,
    closing_balance: 15500
  },
];

new ngxCsv(data, 'Stock-Report', options);

`

thanks for quick reply