当前位置: 首页>>代码示例>>C#>>正文


C# Microsoft.Office.Interop.Excel.SeriesCollection方法代码示例

本文整理汇总了C#中Microsoft.Office.Interop.Excel.SeriesCollection方法的典型用法代码示例。如果您正苦于以下问题:C# Microsoft.Office.Interop.Excel.SeriesCollection方法的具体用法?C# Microsoft.Office.Interop.Excel.SeriesCollection怎么用?C# Microsoft.Office.Interop.Excel.SeriesCollection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Office.Interop.Excel的用法示例。


在下文中一共展示了Microsoft.Office.Interop.Excel.SeriesCollection方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: check_Chart

 //检查图表考点,参数分别为考点列表、继续检索的位置、学生图表、答案图表、学生图表对象、答案图表对象
 private int check_Chart(List<OfficeElement> ls, int startPosition, 
     Excel.Chart stuCh, Excel.Chart ansCh, Excel.ChartObject stuObj, Excel.ChartObject ansObj)
 {
     int thisPoint = 0;
     int i, j;
     if (stuCh == null)
         return 0;
     for (i = startPosition; i < ls.Count; i++)
     {
         OfficeElement oe = ls[i];
         if (oe.AttribName == "Value")          //图表数值
         {
             List<List<string>> stuList, ansList;
             stuList = GetValue(stuCh, stuXls);
             ansList = GetValue(ansCh, ansXls);
             for (i = 0; i < stuList.Count && i < ansList.Count; i++)
             {
                 for (j = 0; j < stuList[i].Count && j < ansList[i].Count; j++ )
                     if (stuList[i][j] == ansList[i][j])
                         thisPoint++;
             }
             continue;
         }
         if (oe.AttribName == "Title")          //图表标题
         {
             if (ansCh.ChartTitle.Text == stuCh.ChartTitle.Text)
                 thisPoint += int.Parse(oe.AttribValue);
             continue;
         }
         if (oe.AttribName == "Type")            //图表类型
         {
             if (ansCh.ChartType == stuCh.ChartType)
                 thisPoint += int.Parse(oe.AttribValue);
             continue;
         }
         if (oe.AttribName == "Name")            //图表的工作表名称(只对独立图表有效)
         {
             if (stuObj == null && stuCh.Name == ansCh.Name)
                     thisPoint += int.Parse(oe.AttribValue);
             continue;
         }
         if (oe.AttribName == "Legend")          //图例
         {
             if (stuCh.HasLegend == true && stuCh.Legend.Position == ansCh.Legend.Position)
                 thisPoint += int.Parse(oe.AttribValue);
             continue;
         }
         if (oe.AttribName == "Position")        //图表位置(只对嵌入式的图表有效)
         {
             if (stuObj != null && checkRangeSame(stuObj.TopLeftCell, ansObj.TopLeftCell)
                 && checkRangeSame(stuObj.BottomRightCell, ansObj.BottomRightCell))
                 thisPoint += int.Parse(oe.AttribValue);
             continue;
         }
         if (oe.AttribName == "DataLabels")      //数据标志
         {
             bool check = false, right = true;
             foreach (Excel.Series ser in (Excel.SeriesCollection)ansCh.SeriesCollection(nullobj))
                 if (ser.HasDataLabels == true)
                 {
                     check = true;
                     break;
                 }
             foreach (Excel.Series ser in (Excel.SeriesCollection)stuCh.SeriesCollection(nullobj))
                 if (ser.HasDataLabels != check)
                 {
                     right = false;
                     break;
                 }
             if (right)
                 thisPoint += int.Parse(oe.AttribValue);
             continue;
         }
     }
     return thisPoint;
 }
开发者ID:kaiss78,项目名称:hustoes,代码行数:77,代码来源:correctExcel.cs

示例2: GetValue

 //获取图表中的数据
 private List<List<string>> GetValue(Excel.Chart ch, Excel.Workbook xls)
 {
     int i, j, k, state;
     Excel.SeriesCollection sc = (Excel.SeriesCollection)ch.SeriesCollection(nullobj);
     List<List<string>> res = new List<List<string>>();
     for (i = 1; i <= sc.Count; i++)
     {
         res.Add(new List<string>());
         string seriesFormula = sc.Item(i).Formula;
         int firstComma = seriesFormula.IndexOf(',');
         int secondComma = seriesFormula.IndexOf(',', firstComma + 1);
         int thirdComma = seriesFormula.IndexOf(',', secondComma + 1);
         string yValues = seriesFormula.Substring(secondComma + 1, thirdComma - secondComma - 1);
         for (k = 1, state = 0; state == 0 && k <= xls.Worksheets.Count; k++)
         {
             try
             {
                 Excel.Worksheet ws = (Excel.Worksheet)xls.Worksheets[k];
                 Excel.Range yRange = ws.get_Range(yValues, nullobj);
                 for (j = 1; j <= yRange.Cells.Count; j++)
                 {
                     Excel.Range cell = (Excel.Range)yRange.Cells[j, nullobj];
                     res[i - 1].Add(cell.Value2.ToString());
                 }
                 state = 1;
             }
             catch { }
         }
     }
     return res;
 }
开发者ID:kaiss78,项目名称:hustoes,代码行数:32,代码来源:correctExcel.cs

示例3: GetGraphValueCount

 //获取图表中的数据个数
 private int GetGraphValueCount(Excel.Chart ch, Excel.Workbook xls)
 {
     int i, j, k, state, cnt = 0;
     Excel.SeriesCollection sc = (Excel.SeriesCollection)ch.SeriesCollection(nullobj);
     for (i = 1; i <= sc.Count; i++)
     {
         string seriesFormula = sc.Item(i).Formula;
         int firstComma = seriesFormula.IndexOf(',');
         int secondComma = seriesFormula.IndexOf(',', firstComma + 1);
         int thirdComma = seriesFormula.IndexOf(',', secondComma + 1);
         string yValues = seriesFormula.Substring(secondComma + 1, thirdComma - secondComma - 1);
         for (k = 1, state = 0; state == 0 && k <= xls.Worksheets.Count; k++)
         {
             try
             {
                 Excel.Worksheet ws = (Excel.Worksheet)xls.Worksheets[k];
                 Excel.Range yRange = ws.get_Range(yValues, nullobj);
                 cnt += yRange.Cells.Count;
                 state = 1;
             }
             catch { }
         }
     }
     return cnt;
 }
开发者ID:kaiss78,项目名称:hustoes,代码行数:26,代码来源:testExcel.cs


注:本文中的Microsoft.Office.Interop.Excel.SeriesCollection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。