zoukankan      html  css  js  c++  java
  • C#------Aspose.cells使用方法

    转载:

    http://www.cnblogs.com/muer/p/yaxle.html

    代码:

    public ActionResult ImportData(HttpPostedFileBase file)
    {
      Workbook workbook = new Workbook();
      Worksheet sheet = workbook.Worksheets[0];
    
      Cells cells = sheet.Cells;
      cells[0, 1].PutValue("Income");
      cells[0, 2].PutValue("Expense");
      cells[1, 0].PutValue("Company A");
      cells[2, 0].PutValue("Company B");
      cells[3, 0].PutValue("Company C");
      cells[1, 1].PutValue(10000);
      cells[2, 1].PutValue(20000);
      cells[3, 1].PutValue(30000);
      cells[1, 2].PutValue(8000);
      cells[2, 2].PutValue(15000);
      cells[3, 2].PutValue(28000);
    
      int chartIndex = sheet.Charts.Add(ChartType.Column, 6, 6, 21, 15);
    
      Aspose.Cells.Charts.Chart chart = sheet.Charts[chartIndex];
    
      //第一条柱子
      chart.NSeries.Add("B2:B4", true);
      chart.NSeries.CategoryData = "A2:A4";
      Series aSeries1 = chart.NSeries[0];
      aSeries1.Name = "=B1";
      chart.NSeries.IsColorVaried = true;
      //第二条柱子
      chart.NSeries.Add("C2:C4", true);
      chart.NSeries.CategoryData = "A2:A4";
      Series aSeries2 = chart.NSeries[1];
      aSeries2.Name = "=C1";
      //修改柱子颜色
      aSeries2.Area.ForegroundColor = System.Drawing.Color.Green;
    
      //修改柱形图背景色
      chart.PlotArea.Area.ForegroundColor = System.Drawing.Color.FromArgb(1, 152, 186, 180);
      //修改区域背景色
      chart.ChartArea.Area.ForegroundColor = System.Drawing.Color.White;
      //显示数据表
      chart.ShowDataTable = true;
      //显示分类条
      chart.ShowLegend = true;
      chart.Title.Text = "Income Analysis";
      workbook.Save(path);
      return null;
    }
  • 相关阅读:
    oracle学习篇十:序列
    oracle学习篇九:同义词
    oracle相关常识
    oracle之数据同步:Oracle Sql Loader使用说明(大批量快速插入数据库记录)
    oracle学习篇八:约束
    oracle学习篇七:更新操作、事务处理
    oracle学习篇六:子查询
    oracle学习篇五:组函数,分组统计
    oracle学习篇四:多表查询
    oracle学习篇三:SQL查询
  • 原文地址:https://www.cnblogs.com/tianhengblogs/p/7295999.html
Copyright © 2011-2022 走看看