이 주사를 thankfull, 나는 그것을 테스트 한거야 그것은 작동합니다
Excel.Application application = new Excel.Application();
Excel.Workbook workbook = application.Workbooks.Open(@"C:\Test\Whatever.xlsx");
Excel.Worksheet worksheet = workbook.ActiveSheet;
Excel.Range usedRange = worksheet.UsedRange;
Excel.Range rows = usedRange.Rows;
int count = 0;
foreach (Excel.Range row in rows)
{
if (count > 0)
{
Excel.Range firstCell = row.Cells[1];
string firstCellValue = firstCell.Value as String;
if (!string.IsNullOrEmpty(firstCellValue))
{
row.Interior.Color = System.Drawing.Color.Red;
}
}
count++;
}
workbook.Save();
workbook.Close();
application.Quit();
Marshal.ReleaseComObject(application);
출처
2012-10-04 13:06:13
JMK
사용하는 라이브러리? –
Microsoft.Office.Interop.Excel –
xlWorkSheet.Cells [ "A2", "B2"]을 시도했습니다. Interior.Color = System.Drawing.ColorTranslator.ToOle (System.Drawing.Color.Red); 하지만 그것은 내게 오류 COMException을 제공합니다 –