本文整理汇总了C#中Microsoft.Office.Interop.Excel.Worksheet.ChartObjects方法的典型用法代码示例。如果您正苦于以下问题:C# Worksheet.ChartObjects方法的具体用法?C# Worksheet.ChartObjects怎么用?C# Worksheet.ChartObjects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Office.Interop.Excel.Worksheet
的用法示例。
在下文中一共展示了Worksheet.ChartObjects方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: addGraph
//添加图表路径
private void addGraph()
{
oxml.Path.Add(new OfficeElement("Workbooks", "0"));
if (radioSingleChart.Checked == true)
{
oxml.Path.Add(new OfficeElement("Charts",(comboChart.SelectedIndex + 1).ToString() + ":" + "0")); //该图表是所有图表中的第几个
ch = (Excel.Chart)xls.Sheets[chartIndex[comboChart.SelectedIndex]]; //获取图表
}
else
{
oxml.Path.Add(new OfficeElement("Charts",
(comboSheet.SelectedIndex + 1).ToString() //该工作簿是所有工作簿的第几个
+ ":" + (comboChartInSheet.SelectedIndex + 1).ToString())); //该图表是工作簿里面的第几个图表
ws = (Excel.Worksheet)xls.Sheets[worksheetIndex[comboSheet.SelectedIndex]];
ch = ((Excel.ChartObject)ws.ChartObjects(comboChartInSheet.SelectedIndex + 1)).Chart; //获取图表
}
}
示例2: getChartInSheet
private void getChartInSheet(int index)
{
comboChartInSheet.Items.Clear();
if (index != 0)
{
ws = (Excel.Worksheet)xls.Sheets[index];
chobjs = (Excel.ChartObjects)ws.ChartObjects(nullobj);
//Console.WriteLine(chobjs.Count);
for (int i = 1; i <= chobjs.Count; i++)
{
chobj = (Excel.ChartObject)ws.ChartObjects(i);
ch = chobj.Chart;
string str = chobj.Name + ": ";
try
{
string title = ch.ChartTitle.Text;
str += title;
}
catch { str += "(未命名图表)"; }
comboChartInSheet.Items.Add(str);
}
}
if (comboChartInSheet.Items.Count == 0)
{
comboChartInSheet.Items.Add("(该页无图表!)");
buttonGraph.Enabled = false;
groupGraphPoint.Enabled = false;
}
else
{
buttonGraph.Enabled = true;
groupGraphPoint.Enabled = true;
}
comboChartInSheet.SelectedIndex = 0;
}