如何使用 Epplus 将 Excel 设置仅应用于一个范围
How to apply Excel settings only to a range using Epplus
对于值 i=4 and i=6
,以下将 LightGrey
背景颜色应用到 entire
第 4 行和第 6 行。 问题:有没有什么方法可以改变特定范围内的一行的背景颜色(或任何样式),比如说,从第 1 列到第 10 列的所有行?
int i;
ExcelRow rowRange = ws.Row(i);
ExcelFill RowFill = rowRange.Style.Fill;
RowFill.PatternType = ExcelFillStyle.Solid;
RowFill.BackgroundColor.SetColor(System.Drawing.Color.LightGray);
而不是使用 ws.Row(rowNumber)
使用
var firstColumn = 1;
var lastColumn = 10;
var rowRange = ws.Cells[rowNumber, firstColumn, rowNumber, lastColumn];
//now do styling on rowRange
rowRange
将包含对由您传递给它的值定义的矩形中所有单元格的引用。
对于值 i=4 and i=6
,以下将 LightGrey
背景颜色应用到 entire
第 4 行和第 6 行。 问题:有没有什么方法可以改变特定范围内的一行的背景颜色(或任何样式),比如说,从第 1 列到第 10 列的所有行?
int i;
ExcelRow rowRange = ws.Row(i);
ExcelFill RowFill = rowRange.Style.Fill;
RowFill.PatternType = ExcelFillStyle.Solid;
RowFill.BackgroundColor.SetColor(System.Drawing.Color.LightGray);
而不是使用 ws.Row(rowNumber)
使用
var firstColumn = 1;
var lastColumn = 10;
var rowRange = ws.Cells[rowNumber, firstColumn, rowNumber, lastColumn];
//now do styling on rowRange
rowRange
将包含对由您传递给它的值定义的矩形中所有单元格的引用。