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


C# Workbook.GetPaletteColor方法代码示例

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


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

示例1: btnRun_Click

		private void btnRun_Click(object sender, System.EventArgs e)
		{
			Workbook workbook = new Workbook();
			Worksheet sheet = workbook.Worksheets[0];

            workbook.Version = ExcelVersion.Version2007;


            int maxColor = Enum.GetValues(typeof(ExcelColors)).Length;
            Random random = new Random((int)System.DateTime.Now.Ticks);
            for (int i = 2; i < 40; i++)
            {
                
                ExcelColors backKnownColor = (ExcelColors)(random.Next(1,maxColor / 2));

                sheet.Range["A1"].Text = "Color Name";
                sheet.Range["B1"].Text = "Red";
                sheet.Range["C1"].Text = "Green";
                sheet.Range["D1"].Text = "Blue";
                sheet.Range["E1:K1"].Merge();
                sheet.Range["E1:K1"].Text = "Gradient";
                sheet.Range["A1:K1"].Style.Font.IsBold = true;
                sheet.Range["A1:K1"].Style.Font.Size = 11;

                string colorName = backKnownColor.ToString();
                sheet.Range[string.Format("A{0}",i)].Text = colorName;
                sheet.Range[string.Format("B{0}", i)].Text = workbook.GetPaletteColor(backKnownColor).R.ToString();
                sheet.Range[string.Format("C{0}", i)].Text = workbook.GetPaletteColor(backKnownColor).G.ToString();
                sheet.Range[string.Format("D{0}", i)].Text = workbook.GetPaletteColor(backKnownColor).B.ToString();

                sheet.Range[string.Format("E{0}:K{0}",i)].Merge();
                sheet.Range[string.Format("E{0}:K{0}", i)].Text = colorName;
                sheet.Range[string.Format("E{0}:K{0}", i)].Style.Interior.FillPattern = ExcelPatternType.Gradient;
                sheet.Range[string.Format("E{0}:K{0}", i)].Style.Interior.Gradient.BackKnownColor = backKnownColor;
                sheet.Range[string.Format("E{0}:K{0}", i)].Style.Interior.Gradient.ForeKnownColor = ExcelColors.White;
                sheet.Range[string.Format("E{0}:K{0}", i)].Style.Interior.Gradient.GradientStyle = GradientStyleType.Vertical;
                sheet.Range[string.Format("E{0}:K{0}", i)].Style.Interior.Gradient.GradientVariant = GradientVariantsType.ShadingVariants1;
            }

            sheet.AutoFitColumn(1);
		
			workbook.SaveToFile("Sample.xlsx");

			ExcelDocViewer(workbook.FileName);
		}
开发者ID:spirecomponent,项目名称:.NETExcelLibrary,代码行数:45,代码来源:Form1.cs


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