Skip to main content
Version: 8.1

system.dataset.dataSetToHTML

This function is used in Python Scripting.

Description​

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.

Syntax​

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

Parameters​

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

Returns​

String - The HTML page as a string.

Scope​

Gateway, Vision Client, Perspective Session

Example Output​

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

Table Data
<HTML><HEAD><TITLE>Table Data</TITLE></HEAD>

<BODY>

<TABLE border='1'>

<TR>

<TH>Col 1</TH>

<TH>Col 2</TH>

<TH>Col 3</TH>

</TR>

<TR>

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

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

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

</TR>

<TR>

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

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

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

</TR>

<TR>

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

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

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

</TR>

<TR>

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

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

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

</TR>



</TABLE>

</BODY></HTML>

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)