node-excel-export icon indicating copy to clipboard operation
node-excel-export copied to clipboard

New extra row with [Object] values

Open maubarrerag opened this issue 6 years ago • 4 comments

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

maubarrerag avatar May 11 '19 17:05 maubarrerag

any updates on this issue @maubarrerag ?

Rawia-Intouch avatar Jul 25 '19 11:07 Rawia-Intouch

@Rawia-Intouch not yet.

maubarrerag avatar Jul 31 '19 00:07 maubarrerag

@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

commshep avatar Aug 05 '19 12:08 commshep

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 } ] ); `

Eshwer004 avatar Jul 19 '20 09:07 Eshwer004