Download 3 Overview - Inductive Automation

Transcript
Appendix C. Scripting Functions
826
myList = event.source.parent.getComponent("List")
row = myList.selectedIndex
if row != -1: # make sure there is something selected
myList.data = system.dataset.deleteRow(myList.data, row)
11.4.6 system.dataset.exportCSV
Description
Exports the contents of a dataset as a CSV file, prompting the user to save the file to disk.
Syntax
system.dataset.exportCSV( filename, showHeaders, dataset)
Parameters
String filename - A suggested filename to save as.
boolean showHeaders - If true (1), the CSV file will include a header row.
Dataset dataset - The dataset to export.
Returns
String - The path to the saved file, or None if the action was canceled by the user.
Scope
Client
Examples
This snippet would prompt the user to save the data currently displayed in a Table component to a
CSV file, and would open the file (in an external program, presumably Excel) after a successful save.
table = event.source.parent.getComponent("Table")
filePath = system.dataset.exportCSV("data.csv", 1, table.data)
if filePath != None:
system.net.openURL("file://"+filePath)
See also:
system.dataset.dataSetToCSV
11.4.7 system.dataset.exportExcel
Description
Exports the contents of a dataset as an Excel spreadsheet, prompting the user to save the file to
disk. Uses the same format as the dataSetToExcel function.
Syntax
system.dataset.exportExcel( filename, showHeaders, dataset)
Parameters
String filename - A suggested filename to save as.
boolean showHeaders - If true (1), the spreadsheet will include a header row.
Object[] dataset - A sequence of datasets, one for each sheet in the resulting workbook.
Returns
String - The path to the saved file, or None if the action was canceled by the user.
Scope
© 2013 Inductive Automation