Microsoft Office Tutorials and References
In Depth Information
Chart control
The following Excel host controls are available in the Excel object model:
Chart control
ListObject control
NamedRange control
XMLMappedRange control
Chart control
The Chart control is the Chart object of the object model. The Chart control
can process simple data binding. The Chart control exposes events to do more
interactive operations over the control. An Excel Chart object is loaded with a large
set of options, which will give the Office developers more flexibility in displaying
data dynamically. Some of the key requirements that can be achieved though VSTO
Excel objects are addressed here for your reference. It is possible for the Excel Chart
object to create, destroy, and recreate operations dynamically.
The Excel Chart control has more events, in order to simplify interaction with
users. Event procedures in Microsoft Office Excel 2007 have diverse levels of control
and influence. Excel developers have to note that event procedures in an Excel
worksheet's code unit detect only events in the Excel worksheet, whereas event
procedures in a workbook's code unit can catch events that occur in all of the sheets
within the workbook.
Let's see a small example that shows how to read the range of cell values and
dynamically generate a chart inside the Excel worksheet.
Open Visual Studio 2008 and create a new solution, as before. Write the following
code in the Sheet1.cs file:
private void Sheet1_Startup(object sender, System.EventArgs e)
{
// Chart control object
Microsoft.Office.Tools.Excel.Chart AuthorBookInfo;
// Chart control properties to display
// parameters are chart display properties
AuthorBookInfo = this.Controls.AddChart(75,90,550,150,
"BookReport");
// Type of chart displayed based on the data
AuthorBookInfo.ChartType = Excel.XlChartType.
xlCylinderBarStacked;
// Set the constant value for range of cells
Globals.Sheet1.Range["B1", "B5"].Value2 = 82;
Globals.Sheet1.Range["D1", "D5"].Value2 = 83;
 
Search JabSto ::




Custom Search