Interface IOfficeChartData
Represents access to the linked or embedded data associated with a chart.
Namespace: Syncfusion.OfficeChart
Assembly: Syncfusion.OfficeChart.UWP.dll
Syntax
public interface IOfficeChartData
Properties
Item[Int32, Int32, Int32, Int32]
Gets the particular data range from the chart data.
Declaration
IOfficeDataRange this[int firstRow, int firstCol, int lastRow, int lastCol] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | firstRow | Represents the first row of the chart data. |
System.Int32 | firstCol | Represents the first column of the chart data. |
System.Int32 | lastRow | Represents the last row of the chart data. |
System.Int32 | lastCol | Represents the last column of the chart data. |
Property Value
Type | Description |
---|---|
IOfficeDataRange | Returns the data range specified from the chart data. |
Examples
IPresentation presentation = Presentation.Open("Template.pptx");
ISlide slide = presentation.Slides[0];
//Get the chart from slide
IOfficeChart chart = slide.Shapes[0] as IOfficeChart;
//Get the chart data
IOfficeChartData chartData = chart.ChartData;
//Get the category label, read only
IOfficeDataRange dataRange = chartData[2, 2, 4, 5];
//Set the cell with an integer
dataRange.SetValue(2, 4, 290);
//Set the cell with double value
dataRange.SetValue(3, 3, 23.34);
//Set the cell with a string
dataRange.SetValue(3, 1, "ChartData - 3R1C");
//Set the cell with an object
object value = "@!@#";
dataRange.SetValue(2, 1, "value");
//Save the presentation
presentation.Save("Output.pptx");
//Close the presentation
presentation.Close();
Dim presentation__1 As IPresentation = Presentation.Open("Template.pptx")
Dim slide As ISlide = presentation__1.Slides(0)
'Get the chart from slide
Dim chart As IOfficeChart = TryCast(slide.Shapes(0), IOfficeChart)
'Get the chart data
Dim chartData As IOfficeChartData = chart.ChartData
'Get the category label, read only
Dim dataRange As IOfficeDataRange = chartData(2, 2, 4, 5)
'Set the cell with an integer
dataRange.SetValue(2, 4, 290)
'Set the cell with double value
dataRange.SetValue(3, 3, 23.34)
'Set the cell with a string
dataRange.SetValue(3, 1, "ChartData - 3R1C")
'Set the cell with an object
Dim value As Object = "@!@#"
dataRange.SetValue(2, 1, "value")
'Save the presentation
presentation__1.Save("Output.pptx")
'Close the presentation
presentation__1.Close()
Methods
Clear()
Clears the chart data.
Declaration
void Clear()
Examples
IPresentation presentation = Presentation.Open("Template.pptx");
ISlide slide = presentation.Slides[0];
//Get the chart from slide
IOfficeChart chart = slide.Shapes[0] as IOfficeChart;
//Get the chart data
IOfficeChartData chartData = chart.ChartData;
//Clear the chart data
chartData.Clear();
//Save the presentation
presentation.Save("Output.pptx");
//Close the presentation
presentation.Close();
Dim presentation__1 As IPresentation = Presentation.Open("Template.pptx")
Dim slide As ISlide = presentation__1.Slides(0)
'Get the chart from slide
Dim chart As IOfficeChart = TryCast(slide.Shapes(0), IOfficeChart)
'Get the chart data
Dim chartData As IOfficeChartData = chart.ChartData
'Clear the chart data
chartData.Clear()
'Save the presentation
presentation__1.Save("Output.pptx")
'Close the presentation
presentation__1.Close()
GetValue(Int32, Int32)
Returns the cell value at the specified row and column index.
Declaration
object GetValue(int rowIndex, int columnIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowIndex | One-based row index of the cell to get value from. |
System.Int32 | columnIndex | One-based column index of the cell to get value from. |
Returns
Type | Description |
---|---|
System.Object | Returns value corresponding to the cell. |
Examples
//Create a presentation instance
IPresentation presentation = Presentation.Create();
//Add a blank slide to the presentation
ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);
//Add chart to the slide with position and size
IOfficeChart chart = slide.Charts.AddChart(100, 10, 500, 300);
//Set chart data - Row1
chart.ChartData.SetValue(1, 2, "Jan");
chart.ChartData.SetValue(1, 3, "Feb");
chart.ChartData.SetValue(1, 4, "March");
//Set chart data - Row2
chart.ChartData.SetValue(2, 1, "2011");
chart.ChartData.SetValue(2, 2, "60");
chart.ChartData.SetValue(2, 3, "70");
chart.ChartData.SetValue(2, 4, "80");
//Set chart data - Row3
chart.ChartData.SetValue(3, 1, "2009");
chart.ChartData.SetValue(3, 2, "80");
chart.ChartData.SetValue(3, 3, "70");
chart.ChartData.SetValue(3, 4, "60");
//Set chart data - Row4
chart.ChartData.SetValue(4, 1, "2010");
chart.ChartData.SetValue(4, 2, "60");
chart.ChartData.SetValue(4, 3, "70");
chart.ChartData.SetValue(4, 4, "80");
//Create a new chart series with the name
IOfficeChartSerie serieJan = chart.Series.Add("Jan");
//Set the data range of chart serie – start row, start column, end row, end column
serieJan.Values = chart.ChartData[2, 2, 4, 2];
//Create a new chart series with the name
IOfficeChartSerie serieFeb = chart.Series.Add("Feb");
//Set the data range of chart serie – start row, start column, end row, end column
serieFeb.Values = chart.ChartData[2, 3, 4, 3];
//Create a new chart series with the name
IOfficeChartSerie serieMarch = chart.Series.Add("March");
//Set the data range of chart series – start row, start column, end row, end column
serieMarch.Values = chart.ChartData[2, 4, 4, 4];
//Get the chart data
IOfficeChartData chartData = chart.ChartData;
//Get the value of a particular cell from the chart data
object value = chartData.GetValue(2, 3);
//Save the presentation
presentation.Save("Output.pptx");
//Close the presentation
presentation.Close();
'Create a presentation instance
Dim presentation__1 As IPresentation = Presentation.Create()
'Add a blank slide to the presentation
Dim slide As ISlide = presentation__1.Slides.Add(SlideLayoutType.Blank)
'Add chart to the slide with postion and size
Dim chart As IOfficeChart = slide.Charts.AddChart(100, 10, 500, 300)
'Set chart data - Row1
chart.ChartData.SetValue(1, 2, "Jan")
chart.ChartData.SetValue(1, 3, "Feb")
chart.ChartData.SetValue(1, 4, "March")
'Set chart data - Row2
chart.ChartData.SetValue(2, 1, "2011")
chart.ChartData.SetValue(2, 2, "60")
chart.ChartData.SetValue(2, 3, "70")
chart.ChartData.SetValue(2, 4, "80")
'Set chart data - Row3
chart.ChartData.SetValue(3, 1, "2009")
chart.ChartData.SetValue(3, 2, "80")
chart.ChartData.SetValue(3, 3, "70")
chart.ChartData.SetValue(3, 4, "60")
'Set chart data - Row4
chart.ChartData.SetValue(4, 1, "2010")
chart.ChartData.SetValue(4, 2, "60")
chart.ChartData.SetValue(4, 3, "70")
chart.ChartData.SetValue(4, 4, "80")
'Create a new chart series with the name
Dim serieJan As IOfficeChartSerie = chart.Series.Add("Jan")
'Set the data range of chart serie – start row, start column, end row, end column
serieJan.Values = chart.ChartData(2, 2, 4, 2)
'Create a new chart series with the name
Dim serieFeb As IOfficeChartSerie = chart.Series.Add("Feb")
'Set the data range of chart serie – start row, start column, end row, end column
serieFeb.Values = chart.ChartData(2, 3, 4, 3)
'Create a new chart series with the name
Dim serieMarch As IOfficeChartSerie = chart.Series.Add("March")
'Set the data range of chart series – start row, start column, end row, end column
serieMarch.Values = chart.ChartData(2, 4, 4, 4)
'Get the chart data
Dim chartData As IOfficeChartData = chart.ChartData
'Get the value of a particular cell from the chart data
Dim value As Object = chartData.GetValue(2, 3)
'Save the presentation
presentation__1.Save("Output.pptx")
'Close the presentation
presentation__1.Close()
SetChartData(Object[][])
Sets the chart data in the specified two dimensional object array.
Declaration
void SetChartData(object[][] data)
Parameters
Type | Name | Description |
---|---|---|
System.Object[][] | data | Represents the two dimensional chart data |
SetDataRange(IEnumerable, Int32, Int32)
Sets the chart data in the specified row and column index with the IEnumerable object data.
Declaration
void SetDataRange(IEnumerable enumerable, int rowIndex, int columnIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.IEnumerable | enumerable | IEnumerable object with desired data |
System.Int32 | rowIndex | Row of the first cell where array should be imported. |
System.Int32 | columnIndex | Column of the first cell where array should be imported. |
SetDataRange(Object[][], Int32, Int32)
Sets the chart data in the specified row and column index with the two dimensional object array.
Declaration
void SetDataRange(object[][] data, int rowIndex, int columnIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Object[][] | data | Represents the two dimensional chart data |
System.Int32 | rowIndex | Row of the first cell where array should be imported. |
System.Int32 | columnIndex | Column of the first cell where array should be imported. |
SetValue(Int32, Int32, Double)
Sets the specified value at the specified row and column index.
Declaration
void SetValue(int rowIndex, int columnIndex, double value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowIndex | One-based row index of the cell to set value. |
System.Int32 | columnIndex | One-based column index of the cell to set value. |
System.Double | value | Value to set. |
Examples
IPresentation presentation = Presentation.Open("Template.pptx");
ISlide slide = presentation.Slides[0];
//Get the chart from slide
IOfficeChart chart = slide.Shapes[0] as IOfficeChart;
//Get the chart data
IOfficeChartData chartData = chart.ChartData;
//Get the category label, read only
IOfficeDataRange dataRange = chartData[2, 2, 4, 5];
//Set the cell with an integer
dataRange.SetValue(2, 4, 290);
//Set the cell with double value
dataRange.SetValue(3, 3, 23.34);
//Set the cell with a string
dataRange.SetValue(3, 1, "ChartData - 3R1C");
//Set the cell with an object
object value = "@!@#";
dataRange.SetValue(2, 1, "value");
//Save the presentation
presentation.Save("Output.pptx");
//Close the presentation
presentation.Close();
Dim presentation__1 As IPresentation = Presentation.Open("Template.pptx")
Dim slide As ISlide = presentation__1.Slides(0)
'Get the chart from slide
Dim chart As IOfficeChart = TryCast(slide.Shapes(0), IOfficeChart)
'Get the chart data
Dim chartData As IOfficeChartData = chart.ChartData
'Get the category label, read only
Dim dataRange As IOfficeDataRange = chartData(2, 2, 4, 5)
'Set the cell with an integer
dataRange.SetValue(2, 4, 290)
'Set the cell with double value
dataRange.SetValue(3, 3, 23.34)
'Set the cell with a string
dataRange.SetValue(3, 1, "ChartData - 3R1C")
'Set the cell with an object
Dim value As Object = "@!@#"
dataRange.SetValue(2, 1, "value")
'Save the presentation
presentation__1.Save("Output.pptx")
'Close the presentation
presentation__1.Close()
SetValue(Int32, Int32, Int32)
Sets the value in the specified row and column index of the cell with the integer value.
Declaration
void SetValue(int rowIndex, int columnIndex, int value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowIndex | One-based row index of the cell to set value. |
System.Int32 | columnIndex | One-based column index of the cell to set value. |
System.Int32 | value | Value to set. |
Examples
IPresentation presentation = Presentation.Open("Template.pptx");
ISlide slide = presentation.Slides[0];
//Get the chart from slide
IOfficeChart chart = slide.Shapes[0] as IOfficeChart;
//Get the chart data
IOfficeChartData chartData = chart.ChartData;
//Get the category label, read only
IOfficeDataRange dataRange = chartData[2, 2, 4, 5];
//Set the cell with an integer
dataRange.SetValue(2, 4, 290);
//Set the cell with double value
dataRange.SetValue(3, 3, 23.34);
//Set the cell with a string
dataRange.SetValue(3, 1, "ChartData - 3R1C");
//Set the cell with an object
object value = "@!@#";
dataRange.SetValue(2, 1, "value");
//Save the presentation
presentation.Save("Output.pptx");
//Close the presentation
presentation.Close();
Dim presentation__1 As IPresentation = Presentation.Open("Template.pptx")
Dim slide As ISlide = presentation__1.Slides(0)
'Get the chart from slide
Dim chart As IOfficeChart = TryCast(slide.Shapes(0), IOfficeChart)
'Get the chart data
Dim chartData As IOfficeChartData = chart.ChartData
'Get the category label, read only
Dim dataRange As IOfficeDataRange = chartData(2, 2, 4, 5)
'Set the cell with an integer
dataRange.SetValue(2, 4, 290)
'Set the cell with double value
dataRange.SetValue(3, 3, 23.34)
'Set the cell with a string
dataRange.SetValue(3, 1, "ChartData - 3R1C")
'Set the cell with an object
Dim value As Object = "@!@#"
dataRange.SetValue(2, 1, "value")
'Save the presentation
presentation__1.Save("Output.pptx")
'Close the presentation
presentation__1.Close()
SetValue(Int32, Int32, Object)
Sets the value in the specified row and column index of the cell with the object value.
Declaration
void SetValue(int rowIndex, int columnIndex, object value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowIndex | One-based row index of the cell to set value. |
System.Int32 | columnIndex | One-based column index of the cell to set value. |
System.Object | value | Value to set. |
Examples
IPresentation presentation = Presentation.Open("Template.pptx");
ISlide slide = presentation.Slides[0];
//Get the chart from slide
IOfficeChart chart = slide.Shapes[0] as IOfficeChart;
//Get the chart data
IOfficeChartData chartData = chart.ChartData;
//Get the category label, read only
IOfficeDataRange dataRange = chartData[2, 2, 4, 5];
//Set the cell with an integer
dataRange.SetValue(2, 4, 290);
//Set the cell with double value
dataRange.SetValue(3, 3, 23.34);
//Set the cell with a string
dataRange.SetValue(3, 1, "ChartData - 3R1C");
//Set the cell with an object
object value = "@!@#";
dataRange.SetValue(2, 1, "value");
//Save the presentation
presentation.Save("Output.pptx");
//Close the presentation
presentation.Close();
Dim presentation__1 As IPresentation = Presentation.Open("Template.pptx")
Dim slide As ISlide = presentation__1.Slides(0)
'Get the chart from slide
Dim chart As IOfficeChart = TryCast(slide.Shapes(0), IOfficeChart)
'Get the chart data
Dim chartData As IOfficeChartData = chart.ChartData
'Get the category label, read only
Dim dataRange As IOfficeDataRange = chartData(2, 2, 4, 5)
'Set the cell with an integer
dataRange.SetValue(2, 4, 290)
'Set the cell with double value
dataRange.SetValue(3, 3, 23.34)
'Set the cell with a string
dataRange.SetValue(3, 1, "ChartData - 3R1C")
'Set the cell with an object
Dim value As Object = "@!@#"
dataRange.SetValue(2, 1, "value")
'Save the presentation
presentation__1.Save("Output.pptx")
'Close the presentation
presentation__1.Close()
SetValue(Int32, Int32, String)
Sets the value in the specified row and column index of the cell with the string value.
Declaration
void SetValue(int rowIndex, int columnIndex, string value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rowIndex | One-based row index of the cell to set value. |
System.Int32 | columnIndex | One-based column index of the cell to set value. |
System.String | value | Value to set. |
Examples
IPresentation presentation = Presentation.Open("Template.pptx");
ISlide slide = presentation.Slides[0];
//Get the chart from slide
IOfficeChart chart = slide.Shapes[0] as IOfficeChart;
//Get the chart data
IOfficeChartData chartData = chart.ChartData;
//Get the category label, read only
IOfficeDataRange dataRange = chartData[2, 2, 4, 5];
//Set the cell with an integer
dataRange.SetValue(2, 4, 290);
//Set the cell with double value
dataRange.SetValue(3, 3, 23.34);
//Set the cell with a string
dataRange.SetValue(3, 1, "ChartData - 3R1C");
//Set the cell with an object
object value = "@!@#";
dataRange.SetValue(2, 1, "value");
//Save the presentation
presentation.Save("Output.pptx");
//Close the presentation
presentation.Close();
Dim presentation__1 As IPresentation = Presentation.Open("Template.pptx")
Dim slide As ISlide = presentation__1.Slides(0)
'Get the chart from slide
Dim chart As IOfficeChart = TryCast(slide.Shapes(0), IOfficeChart)
'Get the chart data
Dim chartData As IOfficeChartData = chart.ChartData
'Get the category label, read only
Dim dataRange As IOfficeDataRange = chartData(2, 2, 4, 5)
'Set the cell with an integer
dataRange.SetValue(2, 4, 290)
'Set the cell with double value
dataRange.SetValue(3, 3, 23.34)
'Set the cell with a string
dataRange.SetValue(3, 1, "ChartData - 3R1C")
'Set the cell with an object
Dim value As Object = "@!@#"
dataRange.SetValue(2, 1, "value")
'Save the presentation
presentation__1.Save("Output.pptx")
'Close the presentation
presentation__1.Close()