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


C# Workbook.CreateCellsColor方法代码示例

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


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

示例1: CreateStaticReport

        protected void CreateStaticReport()
        {
            //Intiaalize workbook with xlsx file format
            Workbook workbook = new Workbook();

            //Clear workbook's worksheets
            workbook.Worksheets.Clear();

            //Insert new Worksheet in workbook and name it "New"
            Worksheet worksheet = workbook.Worksheets.Add("New");

            //Insert dummy data in A8, A9 and A10 cells
            worksheet.Cells["A8"].PutValue(34);
            worksheet.Cells["A9"].PutValue(50);
            worksheet.Cells["A10"].PutValue(34);

            //Intialize Cell Area
            CellArea cellArea = new CellArea();

            //Assign Cell Area boundaries
            cellArea.StartColumn = 0;
            cellArea.EndColumn = 0;
            cellArea.StartRow = 0;
            cellArea.EndRow = 0;

            //Add new Sparklines in worksheet's sparlines collection and Assign the area for it
            int index = worksheet.SparklineGroupCollection.Add(SparklineType.Column, worksheet.Name + "!A8:A10", true, cellArea);

            //Initalize Sparklines Group
            SparklineGroup group = worksheet.SparklineGroupCollection[index];

            // change the color of the series if need
            CellsColor cellColor = workbook.CreateCellsColor();
            cellColor.Color = Color.Orange;

            //Asign the group series color
            group.SeriesColor = cellColor;

            if (ddlFileVersion.SelectedItem.Value == "XLS")
            {
                ////Save file and send to client browser using selected format
                workbook.Save(HttpContext.Current.Response, "SparkLines.xls", ContentDisposition.Attachment, new XlsSaveOptions(SaveFormat.Excel97To2003));
            }
            else
            {
                workbook.Save(HttpContext.Current.Response, "SparkLines.xlsx", ContentDisposition.Attachment, new OoxmlSaveOptions(SaveFormat.Xlsx));
            }

            //end response to avoid unneeded html
            HttpContext.Current.Response.End();
        }
开发者ID:babar-raza,项目名称:Aspose_Cells_NET,代码行数:51,代码来源:using-sparklines.aspx.cs

示例2: Run

        public static void Run()
        {
            // ExStart:1
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            // Instantiate a Workbook
            // Open a template file
            Workbook book = new Workbook(dataDir + "Book1.xlsx");
            // Get the first worksheet
            Worksheet sheet = book.Worksheets[0];

            // Use the following lines if you need to read the Sparklines
            // Read the Sparklines from the template file (if it has)
            foreach (SparklineGroup g in sheet.SparklineGroupCollection)
            {
                // Display the Sparklines group information e.g type, number of sparklines items
                Console.WriteLine("sparkline group: type:" + g.Type + ", sparkline items count:" + g.SparklineCollection.Count);
                foreach (Sparkline s in g.SparklineCollection)
                {
                    // Display the individual Sparkines and the data ranges
                    Console.WriteLine("sparkline: row:" + s.Row + ", col:" + s.Column + ", dataRange:" + s.DataRange);
                }
            }


            // Add Sparklines
            // Define the CellArea D2:D10
            CellArea ca = new CellArea();
            ca.StartColumn = 4;
            ca.EndColumn = 4;
            ca.StartRow = 1;
            ca.EndRow = 7;
            // Add new Sparklines for a data range to a cell area
            int idx = sheet.SparklineGroupCollection.Add(SparklineType.Column, "Sheet1!B2:D8", false, ca);
            SparklineGroup group = sheet.SparklineGroupCollection[idx];
            // Create CellsColor
            CellsColor clr = book.CreateCellsColor();
            clr.Color = Color.Orange;
            group.SeriesColor = clr;

            // Save the excel file
            book.Save(dataDir + "Book1.out.xlsx");
            // ExEnd:1

        }
开发者ID:aspose-cells,项目名称:Aspose.Cells-for-.NET,代码行数:46,代码来源:UsingSparklines.cs


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