Other API Samples

Live SpreadsheetGear API Samples

Snippets Chart (Line with Markers)

A sample that creates a line chart with markers from a range of data.

IWorkbook workbook = Factory.GetWorkbook();
IWorksheet worksheet = workbook.ActiveWorksheet;
IRange cells = worksheet.Cells;
cells["B1:E1"].Value =new object[,] { { "North", "South", "East", "West" } };
cells["A2:A5"].Value = new object[,] { { "Q1" }, { "Q2" }, { "Q3" }, { "Q4" } };
cells["B2:E5"].Formula = "=RANDBETWEEN(1000, 10000)";
IChart chart = worksheet.Shapes.AddChart(1, 1, 302, 149).Chart;
chart.SetSourceData(cells["A1:E5"], RowCol.Columns);
chart.ChartType = ChartType.LineMarkers;
Run This Sample
Render Image

Generate an image representation of the results of this sample, which uses the SpreadsheetGear.Drawing.Image class to convert ranges, charts and shapes to images.


Download File

Download an Excel Open XML Workbook (*.xlsx) file with the results of this sample.