Skip to content
Julian Halliwell edited this page Nov 27, 2023 · 5 revisions

Deprecated: from version 3.12.0 use writeCsv() which has many more options

Convert a query to a CSV string.

queryToCsv( query[, includeHeaderRow[, delimiter[, threads ] ] ] )

Required arguments

  • query query

Optional arguments

  • includeHeaderRow boolean default=false: whether the query columns should be included as the first row of the CSV
  • delimiter string default=",": the single delimiter used in the CSV to separate the fields. For tab delimited data, use \t or tab or #Chr( 9 )#.
  • threads numeric default=1: the number of CPU threads to run in parallel (only supported in Lucee and ColdFusion 2021 ). WARNING: running 2 or more parallel threads can cause unexpected results. In particular rows are likely to be assembled out of order. System crashes are also possible so use this option with care!

Chainable? No.

Examples

data = QueryNew( "First,Last", "VarChar,VarChar", [ [ "Susi","Sorglos" ], [ "Frumpo","McNugget" ] ] );
spreadsheet = New spreadsheet();
csv = spreadsheet.queryToCsv( data );
Clone this wiki locally