设为首页 加入收藏

TOP

C# 填充Excel图表、图例背景色(二)
2019-09-17 18:57:41 】 浏览:64
Tags:填充 Excel 图表 图例 景色
Xls.Core.Spreadsheet.Charts;
using System.Drawing; namespace SetFontOfLegendInChart_XLS { class Program { static void Main(string[] args) { //实例化Workbook类的对象,并加载测试文档 Workbook workbook = new Workbook(); workbook.LoadFromFile("test.xlsx"); //获取工作表中的第一个图表 Worksheet ws = workbook.Worksheets[0]; Spire.Xls.Chart chart = ws.Charts[0]; //填充图例背景色 XlsChartFrameFormat x = chart.Legend.FrameFormat as XlsChartFrameFormat; //单色填充 x.Fill.FillType = ShapeFillType.SolidColor; x.ForeGroundColor = Color.Gainsboro; ////渐变色填充 //x.Fill.FillType = ShapeFillType.Gradient; //x.ForeGroundColor = Color.AliceBlue; //x.BackGroundColor = Color.Bisque; ////纹理填充 //x.Fill.FillType = ShapeFillType.Texture; //x.Fill.Texture = GradientTextureType.Bouquet; ////图片填充 //x.Fill.CustomPicture("img.png"); //保存文档 workbook.SaveToFile("output.xlsx", ExcelVersion.Version2010); System.Diagnostics.Process.Start("output.xlsx"); } } } View Code

 

更多Excel背景色填充的方法,可参考以下文章:

1. C# 设置Excel单元格背景色

2. C# 设置Excel表格图片背景

(本文完)

转载请注明出处!

首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇C#直接引用js文件调js里的数据 下一篇ASP.NETMVC 分页

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目