如何使用“excelpackage”来设置颜色或背景 [英] How to set color or background with "excelpackage"
本文介绍了如何使用“excelpackage”来设置颜色或背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用这个软件包:提供的示例文件)
using(var range = worksheet.Cells [1,1, 1,5])
{
range.Style.Fill.PatternType = ExcelFillStyle.Solid;
range.Style.Fill.BackgroundColor.SetColor(Color.DarkBlue);
}
I use this package: ExcelPackage though I can't figure out how to set the background color for the cell. I tried to use this:
ws.Cells["A1"].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
But it shows that the properties are not found.
Sounds like I should use something similar to this:
worksheet.Cell(5, columnIndex + 1).Style = "background-color: red";
But I am not sure how it works and I couldn't find the tutorial for it. Please help.
解决方案
Try something along these lines (Taken from the EPPlus sample files provided):
using (var range = worksheet.Cells[1, 1, 1, 5])
{
range.Style.Fill.PatternType = ExcelFillStyle.Solid;
range.Style.Fill.BackgroundColor.SetColor(Color.DarkBlue);
}
这篇关于如何使用“excelpackage”来设置颜色或背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文