OpenWGA 7.10 - TMLScript reference
AFW.UtilMethod :
csvWriter(config)
On object | AFW.Util |
Usage | Returns a TMLScript object to write csv data to a file or outputstream. |
Description |
CSV Writer (Exporter) Config options:
Column Definition (config.columns): Each column is either a Sting or Object. If String, the itemvalue or metavalue with that name is written (meta if String is all uppercase). In addition the following syntax is allowed: "label|itemname" to write an item with a different label then the itemname. If Object it must have the format {label:<String>, value: <Function(TMLContext)>} Return value: A csvWriter object with one method
The default encoding is utf8. If write() is called without parameter the output is written to the http response. |
Parameters |
config object |
Return value | csvWriter object |
Allowed in script types |
|
Examples |
AFW.Util.csvWriter({ columns: ["Title|TITLE", "CREATED", "ean", "price"], query: "content.structentry.contenttype.name='product'" }).write() // Exports all "products" to the browser Sample for non-WGContent export: var myobjects = WGA.createList([ { name: "Walter", age: 18 }, { name: "Otto", age: 27 } ]) AFW.Util.csvWriter({ columns: [ "name", "age" ], contentlist: myobjects }).write() |