Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# ClosedXML-C中的行和列样式#_C#_Excel_Closedxml - Fatal编程技术网

C# ClosedXML-C中的行和列样式#

C# ClosedXML-C中的行和列样式#,c#,excel,closedxml,C#,Excel,Closedxml,我正在做一个ASP.net Excel项目,我正在尝试向一个特定的单元格(M2、N2、O2、P2、Q2)添加一些不同的颜色(红色) 我试图在wb.Worksheets.add(dt,“Customers”)之后添加一些行

我正在做一个ASP.net Excel项目,我正在尝试向一个特定的单元格(M2、N2、O2、P2、Q2)添加一些不同的颜色(红色)

我试图在wb.Worksheets.add(dt,“Customers”)之后添加一些行 我正在尝试实现这一点:

dt.Rows(13, 14, 15, 16, 17).Style.Fill.BackgroundColor = XLColor.Red;

有两种可能的方法:

dt.Rows(13, 17)... // first and last row as number

dt.Rows("13, 14, 15, 16, 17").... // string with row numbers like in Excel itself
对于特定的单元,您可以使用类似的调用(M2…Q2,如问题中所示):


您可以查看此存储库。它确实有助于将数据导出到excel。
dt.Rows(13, 17)... // first and last row as number

dt.Rows("13, 14, 15, 16, 17").... // string with row numbers like in Excel itself
dt.Range(2, 14, 2, 18)... // row and column numbers for a rectangular area of cells

dt.Range("M2:Q2")... // string like in Excel