spreadsheet

Creates a new spreadsheet workbook and is the entry point to the fluent builder API. Passing "xlsx" (the default) or "xls" selects the workbook format; mutating methods on the returned workbook return the same object, so calls can be chained. Terminal reads such as getCellValue(), info() or toQuery() return data.

spreadsheet([typeOrPath]) → returns any

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

Argument Reference

typeOrPath string
Default: xlsx

Optional workbook type: "xlsx" (default) or "xls". Legacy .xls workbooks can be read but not written.
Values:
  • xlsx
  • xls

Compatibility

RustCFML:

Not supported on wasm32.

Examples
Sample code invoking the spreadsheet function

Build a workbook with a query, a formatted header row and a frozen pane, then write it to disk.

people = queryNew("id,name", "integer,varchar");
queryAddRow(people, {id: 1, name: "Alice"});
Spreadsheet("xlsx")
	.renameSheet("People", 1)
	.addRows(people, 1, 1, true)
	.formatRow({ bold: true, bgcolor: "#dfe6e9" }, 1)
	.addFreezePane(0, 1)
	.write(expandPath("/people.xlsx"), true);

Create an empty workbook and use the Spreadsheet* function form on it.

wb = Spreadsheet();
spreadsheetSetCellValue(wb, "Hello", 1, 1);
writeDump(spreadsheetGetCellValue(wb, 1, 1));

Expected Result: Hello

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

Fork me on GitHub