I would do it that way:
xlWorksheet.Cells[1, 1].Interior.Color = Excel.XlRgbColor.rgbRed;
But don't forget to declare the right using:
using Excel = Microsoft.Office.Interop.Excel;
And I declared the following variables
Excel.Application xlApplication;
Excel.Workbook xlWoorkbook;
Excel.Worksheet xlWorksheet;
xlApplication = new Excel.Application();
xlWoorkbook = xlApplication.Workbooks.Add();
xlWorksheet = xlWoorkbook.Worksheets[1];
Hopefully that works for you too!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.