andreyan-andreev / node-excel-export

130 stars 53 forks source link

New extra row with [Object] values #51

Open maubarrerag opened 5 years ago

maubarrerag commented 5 years ago

After exporting excel i noticed that a new row was added, not sure where that data came from, data is ok. var specs = { UnitId: {width:80}, type: {width:100},fecha: {width:200}, latitude:{width:100}, longitude: {width:100}, engineSpeed: {width:80}, totalUsedFuel:{width:80}, fuelRate:{width:80}, fuelLevel: {width:80} };

var dataset = data; var report = excel.buildExport([{ name: 'KPIs', heading: heading, specification: specs, data: dataset }]);

Do i need to specify the merge param? Captura de Pantalla 2019-05-11 a la(s) 12 47 48

Rawia-Intouch commented 5 years ago

any updates on this issue @maubarrerag ?

maubarrerag commented 5 years ago

@Rawia-Intouch not yet.

commshep commented 5 years ago

@andreyan-andreev Hey, can you push this one: https://github.com/andreyan-andreev/node-excel-export/pull/49 ? it seems that it will fix the current issue

Eshwer004 commented 4 years ago

I was able to export an excel file without a second row with [Object]. This usually happens when we do not pass the headerStyle in specification. Pass an empty object ({}) and it'll resolve our problem. Here's my code

` //Here you specify the export structure const specification = { customer_name: { // <- the key should match the actual data key displayName: 'Customer', // <- Here you specify the column header headerStyle: {}, // <- Header style width: 120 // <- width in pixels }, status_id: { displayName: 'Status', headerStyle: {}, width: '10' // <- width in chars (when the number is passed as string) } }

const dataset = [ {customer_name: 'IBM', status_id: 1}, {customer_name: 'HP', status_id: 0}, {customer_name: 'MS', status_id: 0} ]

return excel.buildExport( [ // <- Notice that this is an array. Pass multiple sheets to create multi sheet report { name: 'Sales', // <- Specify sheet name (optional) heading: [], // <- Raw heading array (optional) specification: specification, // <- Report specification data: dataset // <-- Report data } ] ); `