Skip to main content
Version: 8.1


This function is used in Python Scripting.


Formats the contents of a dataset as an HTML page, returning the results as a string. Uses the <table> element to create a data table page.

Client Permission Restrictions

This scripting function has no Client Permission restrictions.


system.dataset.dataSetToHTML(showHeaders, dataset, title)


BooleanshowHeadersIf true, the HTML table will include a header row.
DatasetdatasetThe dataset to export.
StringtitleThe title for the HTML page.


String - The HTML page as a string.


Gateway, Vision Client, Perspective Session

Example Output

Expand the panel below to see an example of the resulting HTML this function returns.

Table Data


<TABLE border='1'>


<TH>Col 1</TH>

<TH>Col 2</TH>

<TH>Col 3</TH>



<TD align='right'>58</TD>

<TD align='left'>Test Row 3</TD>

<TD align='right'>27.524042612227795</TD>



<TD align='right'>87</TD>

<TD align='left'>Test Row 10</TD>

<TD align='right'>43.48674729787205</TD>



<TD align='right'>29</TD>

<TD align='left'>Test Row 15</TD>

<TD align='right'>82.46334440414927</TD>



<TD align='right'>3</TD>

<TD align='left'>Test Row 120</TD>

<TD align='right'>15.07317567946509</TD>




Code Examples

Code Snippet
# Get dataset from a Table component
dataset = event.source.parent.getComponent('Table').data

# Format dataset as HTML string
showHeaders = True
title = "Table Data"
html = system.dataset.dataSetToHTML(showHeaders, dataset, title)

# Choose filepath for output
filePath = "C:\\output\\results.html"

# Write the HTML to a file
system.file.writeFile(filePath, html)
Code Snippet
# This snippet would run a SQL query against a database, and turn the results into a string containing HTML. It then writes the string to a file on the local hard drive.

results = system.db.runNamedQuery("Fetch Records",{})
html = system.dataset.dataSetToHTML(1, results, "Production Report")
filePath = "C:\\output\\results.html"
system.file.writeFile(filePath, html)


system dataset dataSetToHTML, dataset.dataSetToHTML