spreadsheetFromJson

Creates a new spreadsheet workbook from a JSON array. An array of objects becomes a header row (the keys of the first object) followed by one data row per object; an array of arrays becomes a raw grid of cells. The fluent member form is fromJson(json), which replaces the contents of the active sheet.

spreadsheetFromJson(json) → returns any

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

Argument Reference

json string
Required

A JSON string: an array of row objects or an array of arrays of cell values.

Compatibility

RustCFML:

Not supported on wasm32.

Examples
Sample code invoking the spreadsheetFromJson function

A JSON array of objects becomes a header row plus data rows.

json = serializeJSON([ {name: "Alice", score: 90}, {name: "Bob", score: 75} ]);
wb = spreadsheetFromJson(json);
writeDump(spreadsheetToQuery(wb));

A JSON array of arrays becomes a raw grid.

wb = spreadsheetFromJson(serializeJSON([ ["a", "b"], ["1", "2"] ]));
writeDump(spreadsheetGetCellValue(wb, 1, 1));

Expected Result: a

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

Fork me on GitHub