# Dataset export to Excel template

**URL:** <https://forum.inductiveautomation.com/t/dataset-export-to-excel-template/5680>\
**Category:** Ignition\
**Created:** [January 14, 2013, 8:17am UTC](https://forum.inductiveautomation.com/t/dataset-export-to-excel-template/5680 "2013-01-14T08:17:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://forum.inductiveautomation.com/u/Ivan)\
**Post date:** [January 14, 2013, 8:17am UTC](https://forum.inductiveautomation.com/t/dataset-export-to-excel-template/5680/1 "2013-01-14T08:17:08Z")

</div>

It would be nice to be able to export from a dataset to an Excel template (eg in order to have a graph automatically created on the Excel spreadsheet).

Thanks.

---

<div class="post-metadata">

**Author:** ![WKetcham](https://avatars.discourse-cdn.com/v4/letter/w/c57346/32.png) [@WKetcham](https://forum.inductiveautomation.com/u/WKetcham)\
**Post date:** [January 19, 2013, 1:41am UTC](https://forum.inductiveautomation.com/t/dataset-export-to-excel-template/5680/2 "2013-01-19T01:41:32Z")

</div>

If you are not afraid of a bit of VBA programming you can create this functionality easy enough. One method would be to

1. Create your Excel template that graphs some data range (I’ll call it “myTemplate.xls”).

2. Save the dataSet to a temp Excel or csv file to a hard coded location and file name. For example to c:\Temp\myData.xls

3. Create another Excel workbook called “myCode.xls” for instance. Then write a macro subroutine (call this subroutine from the Auto\_Open() procedure) that creates a new workbook from myTemplate.xls. Then opens myData.xls, copies the data out of it and pastes it into the the graph data range of your new workbook. Closes and kills myData.xls. Then finally closes itself. What should be left on your screen is your new workbook with a pretty graph.

To make it all work from Ignition, create the temp file as you have been doing (but not open Excel doing it). Then open myCode.xls using system.util.execute.

It might seem a bit cumbersome but it works pretty well. I used to do something almost exactly like this in Wonderware to create automated reports.

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://forum.inductiveautomation.com/u/Ivan)\
**Post date:** [January 25, 2013, 8:22am UTC](https://forum.inductiveautomation.com/t/dataset-export-to-excel-template/5680/3 "2013-01-25T08:22:00Z")

</div>

Thanks a lot for sharing, I’ll try that out!

---

<div class="post-metadata">

**Author:** ![WKetcham](https://avatars.discourse-cdn.com/v4/letter/w/c57346/32.png) [@WKetcham](https://forum.inductiveautomation.com/u/WKetcham)\
**Post date:** [January 25, 2013, 6:33pm UTC](https://forum.inductiveautomation.com/t/dataset-export-to-excel-template/5680/4 "2013-01-25T18:33:57Z")

</div>

No problem, feel free to shoot me a message if you run into any hiccups with the VBA end.
