是否可以在EPPlus中为整列设置样式?我希望我可以使用这个Column方法,但是当我这样做时,我会得到奇怪的结果:
//Sets all cells in all columns to Red
worksheet.Column(1).Style.Font.Color.SetColor(Color.Red);
//Sets some cells in column B to red.
worksheet.Column(2).Style.Font.Color.SetColor(Color.Red);
Run Code Online (Sandbox Code Playgroud)
在这两种情况下,我在添加一些标题行之后设置颜色,但在添加大量行之前,我没有在其他地方设置颜色.我也得到了类似的意外结果设置水平对齐.目前我不得不在单元格级别设置样式.
我使用不正确还是这个错误?使用EPPlus 3.1.2.0和Excel 2010(14.0.6129.5000).
小智 10
int indexOfColumn = ...;
worksheet.Column(indexOfColumn).Style.Font.Color.SetColor(Color.Red);
Run Code Online (Sandbox Code Playgroud)
小智 7
尝试使用范围; 我也遇到了使用数字的问题.
//Get the final row for the column in the worksheet
int finalrows = worksheet.dimension.End.Row;
//Convert into a string for the range.
string ColumnString = "A1:A" + finalrows.ToString();
//Convert the range to the color Red
worksheet.Cells[ColumnString].Style.Font.Color.SetColor(Color.Red);
Run Code Online (Sandbox Code Playgroud)
希望这有效,但我没试过.
| 归档时间: |
|
| 查看次数: |
17010 次 |
| 最近记录: |