csvWrite

Writes data such as a query, array of structs or array of arrays as CSV.

csvWrite(data, inputFormat, destinationFilePath [, writeConfiguration]) → returns void

This function requires Adobe ColdFusion 2025 and up.  Not supported on Lucee, etc.

Argument Reference

data any
Required

The data to write.

inputFormat string
Required

Format of the data being written.
Values:
  • csvstring
  • arrayofcfarray
  • arrayofjavaarray
  • arrayofstruct
  • query
  • xlsx
  • csvrecorditerable

destinationFilePath string
Required

Path of the file to write the CSV to.

writeConfiguration struct

Struct of output options. Keys include delimiter, quoteCharacter, quoteMode, escapeCharacter, encoding, recordSeparator, headerComments, nullString, trim, trailingDelimiter, autoflush, duplicateHeaderMode and readCSVConfig.

Examples
Sample code invoking the csvWrite function

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub