Adds a chart to the active sheet of a spreadsheet workbook. The chart struct accepts type (line, line3d, bar, bar3d, pie, pie3d, doughnut or area, default line), series (an array or delimited list of sheet-qualified ranges such as "Sheet1!$A$2:$A$10"), from and to (anchor A1 cells) and an optional title. The fluent member form is addChart({...}).
spreadsheetAddChart(spreadsheetObj, { type, series, from, to, title })
→ returns any
Write scores to a sheet, then add a bar chart anchored at E1.
scores = queryNew("name,score", "varchar,integer");
queryAddRow(scores, {name: "Alice", score: 90});
queryAddRow(scores, {name: "Bob", score: 75});
Spreadsheet("xlsx")
.sheet("Data")
.fromQuery(scores, true)
.addChart({
type: "bar",
series: ["Data!$B$2:$B$3"],
from: "E1",
to: "L15",
title: "Scores"
})
.write(expandPath("/chart.xlsx"), true);
Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.