spreadsheetWriteToCsv

Writes the active sheet of a spreadsheet workbook to a CSV file. Fields containing the delimiter, a quote or a newline are quoted, with embedded quotes doubled. The fluent member form is writeToCsv(filePath, delimiter) (alias writeCsv).

spreadsheetWriteToCsv(spreadsheetObj, filePath [, delimiter]) → returns any

This function requires RustCFML.  Not supported on Lucee, Adobe ColdFusion, etc.

Argument Reference

spreadsheetObj any
Required

The spreadsheet workbook object.

filePath string
Required

Path of the CSV file to write.

delimiter string
Default: ,

Field delimiter (default comma).

Compatibility

RustCFML:

Not supported on wasm32.

Examples
Sample code invoking the spreadsheetWriteToCsv function

Build a small workbook and write it to a CSV file.

wb = Spreadsheet("xlsx");
spreadsheetAddRow(wb, "name,score", 1, 1, false);
spreadsheetAddRow(wb, "Alice,90", 2, 1, false);
spreadsheetWriteToCsv(wb, expandPath("/out.csv"));
writeDump(fileRead(expandPath("/out.csv")));

Expected Result: name,score Alice,90

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

Fork me on GitHub