0
我創建了一個基於DataSet
的Excel文件,我想添加一個帶紅綠燈的列。Excel添加交通信號燈
紅綠燈:
int trafficCollor = 1;
if (trafficCollor == 1)
{
DataRow NR = DT.NewRow();
NR[0] = ""; //add string with the code for the Excel traffic light yellow
}
if (trafficCollor < 1)
{
DataRow NR = DT.NewRow();
NR[0] = ""; //add string with the code for the Excel traffic light green
}
if (trafficCollor > 1)
{
DataRow NR = DT.NewRow();
NR[0] = ""; //add string with the code for the Excel traffic light red
}
如何在Excel中創建了:
//Create an Excel application instance
Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook excelWorkBook = excelApp.Application.Workbooks.Add();
Microsoft.Office.Interop.Excel._Worksheet worksheet = null;
excelApp.Visible = false;
worksheet = excelWorkBook.ActiveSheet;
//set headers
for (int i = 1; i < DGV.Columns.Count + 1; i++)
{
worksheet.Cells[1, i] = DGV.Columns[i - 1].HeaderText;
}
createList(worksheet, DGV);
//Create excel with the choosen name
Worksheet sheet1 = excelWorkBook.Worksheets[1];
worksheet.Name = fileName;
如果您有任何建議,存檔這樣的事情,讓我知道!
你是如何創建Excel文件?您無法將條件格式添加到「DataTable」中。 –
@Charles Mager請參閱編輯.. –
我沒有看到您在代碼中使用條件格式進行任何操作? –