# Using client script to generate html export of a table

**URL:** <https://forum.inductiveautomation.com/t/using-client-script-to-generate-html-export-of-a-table/4196>\
**Category:** Ignition\
**Created:** [March 22, 2012, 9:34pm UTC](https://forum.inductiveautomation.com/t/using-client-script-to-generate-html-export-of-a-table/4196 "2012-03-22T21:34:10Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![diat150](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@diat150](https://forum.inductiveautomation.com/u/diat150)\
**Post date:** [March 22, 2012, 9:34pm UTC](https://forum.inductiveautomation.com/t/using-client-script-to-generate-html-export-of-a-table/4196/1 "2012-03-22T21:34:10Z")

</div>

I have a table on a window that gets automatically refreshed every 5 minutes. every 30 minutes or so, I would like to export the table to html and overwrite the existing html that was previously generated. what is the best way to accomplish this?

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [March 22, 2012, 10:31pm UTC](https://forum.inductiveautomation.com/t/using-client-script-to-generate-html-export-of-a-table/4196/2 "2012-03-22T22:31:40Z")

</div>

You can add a timer component to the window that is set to run every 30 minutes. On the actionPerformed event you can put a script like this:`data = event.source.parent.getComponent("Table")
html = system.dataset.dataSetToHTML(1, data, "Production Report")
filePath = "C:\\output\\results.html"
system.file.writeFile(filePath, html)`That will override the file every 30 minutes.

---

<div class="post-metadata">

**Author:** ![diat150](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@diat150](https://forum.inductiveautomation.com/u/diat150)\
**Post date:** [March 22, 2012, 10:59pm UTC](https://forum.inductiveautomation.com/t/using-client-script-to-generate-html-export-of-a-table/4196/3 "2012-03-22T22:59:04Z")

</div>

That doesnt seem to work for me, I get this error:

[code]Traceback (innermost last):

File “event:actionPerformed”, line 2, in ?

TypeError: dataSetToHTML(): 2nd arg can’t be coerced to com.inductiveautomation.ignition.common.Dataset

Ignition v7.2.11-beta1 (b209)  
Java: Sun Microsystems Inc. 1.6.0\_30  
[/code]

this is the command I am currently using to export, but it asks me to save the file, I just want it to save automatically in a certain path. Any way I can tell this command which path to use and not to prompt me for the path?

```auto
event.source.parent.getComponent("Table").exportHTML("data.html", event.source.parent.getComponent('Path').text, 600)
```

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [March 22, 2012, 11:09pm UTC](https://forum.inductiveautomation.com/t/using-client-script-to-generate-html-export-of-a-table/4196/4 "2012-03-22T23:09:46Z")

</div>

Sorry, you need to get the table’s data property. Try this:`data = event.source.parent.getComponent("Table").data
html = system.dataset.dataSetToHTML(1, data, "Production Report")
filePath = "C:\\output\\results.html"
system.file.writeFile(filePath, html)`

---

<div class="post-metadata">

**Author:** ![diat150](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@diat150](https://forum.inductiveautomation.com/u/diat150)\
**Post date:** [March 22, 2012, 11:26pm UTC](https://forum.inductiveautomation.com/t/using-client-script-to-generate-html-export-of-a-table/4196/5 "2012-03-22T23:26:18Z")

</div>

Almost, but not quite! It’s exporting all of the hidden columns whereas the function I am using above only exports visible columns. Any way to make it work like the other function and only show the visible columns?

Thanks

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [March 22, 2012, 11:50pm UTC](https://forum.inductiveautomation.com/t/using-client-script-to-generate-html-export-of-a-table/4196/6 "2012-03-22T23:50:19Z")

</div>

Ok, here you go:`table = event.source.parent.getComponent("Table")
html = table.getDataAsHTML(event.source.parent.getComponent('Path').text, 600)
filePath = "C:\\output\\results.html"
system.file.writeFile(filePath, html)`

---

<div class="post-metadata">

**Author:** ![diat150](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@diat150](https://forum.inductiveautomation.com/u/diat150)\
**Post date:** [March 23, 2012, 12:34pm UTC](https://forum.inductiveautomation.com/t/using-client-script-to-generate-html-export-of-a-table/4196/7 "2012-03-23T12:34:33Z")

</div>

thanks, that did it.
