簡體   English   中英

excel片的着色細胞

[英]coloring cells of excel sheet

我想在 c# 中為 excel 表的某些特定單元格着色。 但我沒有得到它..我使用的代碼是:

  dsNew.Tables[0].Columns[j].Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.DeepPink);

但這不是 wrking.. 如何做到這一點.. 請做點什么.. 它給出一個錯誤“無法解析符號'內部'”

嘗試Range.Interior屬性:

Range data_cell = work_sheet.Cells[row, column];
data_cell.Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.DeepPink);

其中work_sheet是您希望更改其單元格的 Excel.Worksheet。 rowcolumn或要更改的單元格的索引。

您的示例可能會為列索引器返回 object。 嘗試這個:

((Range)dsNew.Tables[0].Columns[j]).Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.DeepPink);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM