--- title: "system.dataset.dataSetToHTML" description: "Formats the contents of a dataset as an HTML page, returning the results as a string." --- # system.dataset.dataSetToHTML > Formats the contents of a dataset as an HTML page, returning the results as a string. This function is used in **Python Scripting**. ## Description Formats the contents of a [dataset](platform/scripting/python-scripting/variables-datatypes-and-objects/datasets.md) as an HTML page, returning the results as a string. Uses the `` element to create a data table page. ## Client Permission Restrictions This scripting function has no [Client Permission](../../../ignition-modules/vision/vision-project-properties/vision-project-properties.md#vision-permissions-properties) restrictions. ## Syntax `system.dataset.dataSetToHTML(showHeaders, dataset, title)` ### Parameters Type | Parameter | Description ------- | ------- | ------- 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 ## Example Output Expand the panel below to see an example of the resulting HTML this function returns.
Table Data ``` Table Data
Col 1 Col 2 Col 3
58 Test Row 3 27.524042612227795
87 Test Row 10 43.48674729787205
29 Test Row 15 82.46334440414927
3 Test Row 120 15.07317567946509
``` ## Code Examples ```python title="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) ``` ```python title="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) ```