# Need help on "dataSetToExcel"

**URL:** <https://forum.inductiveautomation.com/t/need-help-on-datasettoexcel/9390>\
**Category:** Ignition\
**Created:** [November 28, 2014, 2:06pm UTC](https://forum.inductiveautomation.com/t/need-help-on-datasettoexcel/9390 "2014-11-28T14:06:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dhananjay\_vichare](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dhananjay_vichare/32/74712_2.png) [@dhananjay\_vichare](https://forum.inductiveautomation.com/u/dhananjay_vichare)\
**Post date:** [November 28, 2014, 2:06pm UTC](https://forum.inductiveautomation.com/t/need-help-on-datasettoexcel/9390/1 "2014-11-28T14:06:19Z")

</div>

I want to export the query results data to an excel sheet with some formatting.

Right now, the below code exports the data to excel sheet as shown in below snapshot “Exported\_Data”.

I want to include the (Report details) “HeaderRow = [0,"Report Date: " + ReportDate,1, "Location: "+ LocSel, 2, " Equipment: "+ EquieSel]” above the table header (Serial No., GPM) for reporting purpose. Please refer snapshot “Report\_Formatted”

Could I do the cell formatting and table borders in excel by scripts?

I have inserted the header row at row 0 (Marked in red colour), but still it showing under the table header.

Thanks in advance.

Code :  
Filename = “Report\_” + dateOut + “_" +LocSel+"_” +EquieSel+ “.xls”  
results = system.db.runQuery(Query,“Equipment\_DB\_MySQL\_Connection”)  
result = system.dataset.toDataSet(results)  
[color=#FF0000]HeaderRow = [0,"Report Date: " + ReportDate,1, "Location: "+ LocSel, 2, " Equipment: "+ EquieSel][/color]  
Heading = system.dataset.addRow(result,0,HeaderRow)  
spreadsheet = system.dataset.dataSetToExcel(1, [Heading])  
filePath = “C:\output\” + Filename  
system.file.writeFile(filePath, spreadsheet)  
system.net.openURL(“C:\output\” + Filename)   
 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/4/4cc710f82ee5c3bbbca966aaa941445125337bcb.png)

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/2/25555c2b88e94661a287742feade13c5510679f1.png)
