Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Scripting_function


Panel
titleDescription

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 permissions restrictions


Panel
titleSyntax

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

  • Parameters

Boolean showHeaders - If true, the HTML table will include a header row.

Dataset dataset - The dataset to export.

String title - The title for the HTML page.

  • Returns

String - The HTML page as a string.

  • Scope

Gateway, Vision Client, Perspective Session

Panel
titleExample Output

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

Expand
Code Block
languagexml
linenumberstrue
<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 12<120</TD>

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

</TR>



</TABLE>

</BODY></HTML>

Panel
titleCode Examples
Code Block
languagepy
titleCode 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 Block
languagepy
titleCode 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)
Panel
titleKeywords

system dataset dataSetToHTML, dataset.dataSetToHTML