c# excel how to change a color of a particular row

后端 未结 2 821
一整个雨季
一整个雨季 2020-12-11 02:59

I want to ask you guys, how to change color of a row to red in Excel table if the cell 1 isn\'t null.

XX     YY     ZZ
-----------------
aa     bb     cc
aa1         


        
2条回答
  •  被撕碎了的回忆
    2020-12-11 03:53

    Excel.Application xlAppToExport = new Excel.Application();
    xlAppToExport.Workbooks.Add("");
    Excel.Worksheet xlWorkSheetToExport = default(Excel.Worksheet);
    xlWorkSheetToExport = (Excel.Worksheet)xlAppToExport.Sheets["Sheet1"];
    
    xlWorkSheetToExport.Range["A5:F5"].EntireRow.Interior.Color = System.Drawing.Color.Gray;
    

提交回复
热议问题