[]
Sets the source data range for the chart and specifies whether each data series is taken from rows or columns.
Use the plotBy parameter to control how the chart interprets the source range when creating series and categories.
void SetSourceData(IRange source, RowCol plotBy)
Sub SetSourceData(source As IRange, plotBy As RowCol)
| Type | Name | Description |
|---|---|---|
| IRange | source | The range that contains the source data. Must not be |
| RowCol | plotBy | Specifies whether the chart reads each data series from Columns or Rows. |
worksheet.Range["A1:C4"].Value = new object[,] {
{"Month", "North", "South"},
{"Jan", 10, 12},
{"Feb", 15, 18},
{"Mar", 13, 16}
};
IChart chart = worksheet.Shapes.AddChart(ChartType.ColumnClustered, 20, 20, 300, 200).Chart;
chart.SetSourceData(worksheet.Range["A1:C4"], RowCol.Columns);
Sets the source data range for the chart.
The specified range is used as the chart's data source.
void SetSourceData(IRange source)
Sub SetSourceData(source As IRange)
| Type | Name | Description |
|---|---|---|
| IRange | source | The range that contains the source data. Must not be |
IRange range = worksheet.Range["A1:B4"];
range.Value = new object[,] {
{"Month", "Sales"},
{"Jan", 10},
{"Feb", 15},
{"Mar", 12}
};
IChart chart = worksheet.Shapes.AddChart(ChartType.ColumnClustered, 20, 20, 300, 200).Chart;
chart.SetSourceData(range);