Skip to content
Julian Halliwell edited this page Sep 20, 2021 · 14 revisions

Adds a row to a spreadsheet.

addRow( workbook, data [, row [ , column  [, insert  [, delimiter  [, handleEmbeddedCommas [, autoSizeColumns [, datatypes ] ] ] ] ] ] ] )

Required arguments

  • workbook spreadsheet object
  • data string OR array: Delimited list of data, one list item per column being added to the row. The default delimiter is a comma, but you can specify a different delimiter. (Version 2.1+) The data can be an array of values instead of a list.

Optional arguments

  • row numeric: Row number at which to insert or replace the data. When inserting, existing rows below will be shifted down. If you omit this value, the row is inserted after the last row in the sheet.
  • column numeric: The column at which to add the row data. Cells to the left of this column will be empty.
  • insert boolean default=true: whether to insert the new data or replace existing values. If replacing (insert=false), you will need to specify the row to replace.
  • delimiter string default=",": the character separating cell values in your row. If your values contain commas, use an alternative delimiter not contained in your data, e.g. |
  • handleEmbeddedCommas boolean default=true: whether to treat values enclosed in single quotes as a single element (to match ColdFusion). This only applies if the delimiter is a comma.
  • autoSizeColumns boolean default=false: whether to adjust the column widths automatically to fit the data added.
  • datatypes struct: specify data types as keys and the columns they should apply to in your data as an array of column names or (positional) numbers. These types will override the query column types or auto-detection where possible. Possible data type keys are: string, numeric, date, time, boolean, auto. See addRows() for examples.

Chainable? Yes.

Examples

spreadsheet = New spreadsheet();
workbook = spreadsheet.new();
spreadsheet.addRow( workbook, "a,b" );
// If your data contains commas, use a different delimiter
spreadsheet.addRow( workbook=workbook, data="Champion, the wonder horse|Bagpuss", delimiter="|" );
// Add data as an array
spreadsheet.addRow( workbook, [ "Champion, the wonder horse", "Bagpuss" ] );
Clone this wiki locally