Save to Excel Workbook
Command Description
Save Datasheet to Excel Workbook
Command Prototype
Datatable.SaveToExcel(dtTable, sheetName, path, bIncludeColHead)
Command parameter
parameter | mandatory | type | default value | Instructions |
---|---|---|---|---|
dtTable | True | expression | objDatatable | A data table object saved as an Excel file, usually the return value of the "Build Data Table" command or the "Build Data Table from Excel Table" command |
sheetName | True | string | "Sheet1" | Specify a worksheet in an Excel table. You can fill in the name of the worksheet (such as "Sheet1") or the order value of the worksheet (such as 0), which must be an integer value starting from 0, that is, the order of the first worksheet is 0, the order of the second worksheet is 1, and so on |
path | True | path | ''' C:\Users''' | Specify the specific path to save as Excel file. Only '. xls','. xlsx 'and'. xlsm 'formats are supported. It is recommended to select'. xlsx 'format. If the saved Excel file does not exist, create the file; If the Excel file saved as already exists and the format is'. xlsx 'or'. xlsm ', the content will be overwritten if the internal specified worksheet already exists, or created if the specified worksheet does not exist; If the Excel file saved as already exists and the format is'. xls', the existing Excel file will be overwritten directly All and only the specified worksheet content will be retained |
bIncludeColHead | True | boolean | True | Whether to write the column header of the data table to the Excel file. The default is Yes. When No is selected, the column headers of the data table will not be written to the Excel file |
Return result
Run instance
/*********************************Save to Excel Workbook*********************************
Command Prototype:
Datatable.SaveToExcel(dtTable, sheetName, path, bIncludeColHead)
Input Parameters:
dtTable -- Data table object. Note: The data table object to be saved as an Excel file, typically the return value of the "Build Data Table" command or the "Build Data Table from Excel" command.
sheetName -- Worksheet name. Note: Specify the worksheet in the Excel file. You can fill in the name of the worksheet (e.g., "Sheet1") or the index of the worksheet (e.g., 0). Must be an integer value starting from 0, i.e., the first worksheet has index 0, the second has index 1, and so on.
path -- Save path. Note: Specify the specific path to save the Excel file. Only supports '.xls', '.xlsx', '.xlsm' formats. The '.xlsx' format is recommended. If the target Excel file does not exist, it will be created. If the target Excel file already exists and the format is '.xlsx' or '.xlsm', the content will be overwritten if the specified worksheet exists, or a new worksheet will be created if it doesn't exist. If the target Excel file already exists and the format is '.xls', the entire file will be overwritten, retaining only the content of the specified worksheet.
bIncludeColHead -- Include column headers. Note: Whether to write the data table's column headers to the Excel file. Default is "Yes". When set to "No", the column headers will not be written to the Excel file.
Output Parameters:
None
Notes:
None
********************************************************************************/
Datatable.SaveToExcel(objDatatable, "Sheet1", '''C:\Users''', True)