【问题标题】:coloring cells of excel sheetexcel表格的着色单元格
【发布时间】:2011-08-17 02:54:39
【问题描述】:

我想在 c# 中为 excel 表的某些特定单元格着色。但我不明白.. 我将代码用作:

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

但这不工作.. 如何做到这一点.. 请做点什么。。 它给出一个错误“无法解析符号'内部'”

【问题讨论】:

    标签: c# excel colors cells


    【解决方案1】:

    试试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 或要更改的单元格的索引。

    您的示例可能正在为列索引器返回一个对象。试试这个:

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

    【讨论】:

      猜你喜欢
      • 2011-08-19
      • 1970-01-01
      • 1970-01-01
      • 2023-04-07
      • 2014-07-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多