workbookFromCsv - cfsimplicity/spreadsheet-cfml GitHub Wiki
Returns a workbook object from a csv string or a file containing one.
workbookFromCsv( csv, filepath[, firstRowIsHeader[, boldHeaderRow[, trim [, xmlFormat[, delimiter ] ] ] ] ] )
Required arguments
csv
string: the data in CSV format ORfilepath
string: full filesystem path of a file containing CSV data
Optional arguments
firstRowIsHeader
boolean default=false: whether the first line of the CSV contains the column names to use in the queryboldHeaderRow
boolean default=true: whether to make the header row boldtrim
boolean default=true: whether white space should be removed from the beginning and end of the CSV stringxmlformat
boolean default=false: whether to create an XML spreadsheet (.xlsx)delimiter
string default=",": the single delimiter used in the CSV to separate the fields. For tab delimited data, use\t
ortab
or#Chr( 9 )#
.
Chainable? Yes, using spreadsheet.newChainable().fromCsv()
.
Example
spreadsheet = New spreadsheet();
savecontent variable="csv"{
WriteOutput( '
Name,Phone
"Frumpo McNugget",12345
' );
};
spreadsheetObject = spreadsheet.workbookFromCsv( csv=csv, firstRowIsHeader=true );