--- title: "system.dataset.dataSetToExcel" description: "Formats the contents of one or more datasets as an excel spreadsheet, returning the results as a string." --- # system.dataset.dataSetToExcel > Formats the contents of one or more datasets as an excel spreadsheet, returning the results as a string. This function is used in **Python Scripting**. ## Description Formats the contents of one or more datasets as an excel spreadsheet, returning the results as a string. Each dataset specified will be added as a worksheet in the Excel workbook. This function uses an xml-format for Excel spreadsheets, not the native Excel file format. ## Client Permission Restrictions This scripting function has no [Client Permission](projects\project-properties\project-properties.md#client---permissions) restrictions. ## Syntax `system.dataset.dataSetToExcel(showHeaders, datasets[, nullsEmpty])` ### Parameters Type | Parameter | Description ------- | ------- | ------- Boolean | `showHeaders` | If True (1), the spreadsheet will include a header row. Object[] | `datasets` | If True (1), the spreadsheet will include a header row. Boolean | `nullsEmpty` | If True (1), the spreadsheet will leave cells with NULL values empty, instead of allowing Excel to provide a default value like 0. Defaults to False. [Optional] ### Returns **String** - An Excel-compatible XML-based workbook, with one worksheet per dataset. ### Scope All ## Code Examples ```python title="Example 1" # This snippet would run a SQL query against a database, and turn the results into a string that is XML that Excel can open. It then writes the string to a file on the local hard drive. results = system.db.runQuery("SELECT * FROM example1 LIMIT 100") results = system.dataset.toDataSet(results) spreadsheet = system.dataset.dataSetToExcel(1, [results]) filePath = "C:\\output\\results.xls" system.file.writeFile(filePath, spreadsheet) ```