The Interface:NewExportTable function creates an object that provides facilities to assist in the export of information to CSV files. These facilities are described below.
Define a field in the export table. Fields should be defined in the order they must appear in the output file.
Name is the name of the field. Format is how to render it, options are anything acceptable to string.format(). Default is the value to export when not explicitly set in the record, it's subjected to the formatting defined above. Description is purely for documentation purposes.
A field Name can be in any of the following forms:
Where index is numeric. This is useful when the output record consists of sub-records and arrays.
If the Format is nil or ‘’, it means this field should be skipped in the output. This is useful in conjunction with variant records (see fieldis below) when each variant has a different number of output fields. Just add ‘skipped’ fields to make each variant have the same number of field definitions.
Each field must be defined before the first call to ExportTable:add()
Set and/or get the last field number. This is used to create field definition variants, like this:
mark = fieldis() --get field number of last field
fieldis(mark) --reset to prior to 'f1' field#
field('f3') --'f3' is now an alternative definition for the same field# as 'f1'
field('f4') --'f4' is now an alternative definition for the same field# as 'f2'
It's the caller's responsibility to ensure everything lines up appropriately.
Add the given field buffer to the output record list for the table. Fields must be a table of field name/value pairs, where each field name must have been defined by a prior call to ExportTable:field(). Name/value pairs in Fields but not defined by a :field() call are ignored. A field defined but not present is populated with its default value.
If Raw is present and true the given fields are added to the output as is, otherwise they will be quoted if they contain embedded quotes or separators.