OpenWGA 7.10 - TMLScript reference

Method :


On object AFW.Util
Usage Returns a TMLScript object to write csv data to a file or outputstream.

CSV Writer (Exporter)

Config options:

  • columns: Array or List of item (column) definitions. Required.
  • header: optional - an array of header columns.
  • contentlist: List of WGContent-s or TMLContext-s. Optional. If empty, option "query" is used.
  • query: A HQL query defining the contentlist. Optional. If empty, all child-Contents are used.
  • dateFormat: optional date format. If Empty yyyy-MM-dd HH:mm:SS is used.
  • divider: Column divider. Default is Semicolon

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

  • write([filename_or_stream_or_file, [encoding]])

The default encoding is utf8.

If write() is called without parameter the output is written to the http response.


config object

Return value csvWriter object
Allowed in script types
  • WebTML pages and normal WebTML actions
  • Master actions
  • TMLScript tasks in jobs
  • Content type events
	columns: ["Title|TITLE", "CREATED", "ean", "price"],
	query: "'product'"
// Exports all "products" to the browser

Sample for non-WGContent export:

var myobjects = WGA.createList([
        name: "Walter",
        age: 18
        name: "Otto",
        age: 27

    columns: [
    contentlist: myobjects