【问题标题】:How can I check the color of text in a cell of a worksheet?如何检查工作表单元格中文本的颜色?
【发布时间】:2022-07-26 01:09:43
【问题描述】:

如何在 C# epplus WPF 中检查单元格文本颜色是白色还是其他颜色?

在 VBA 中,可以使用以下方法检查单元格的颜色:

excelSheet.Cells(row,Column).Characters(1, 1).Font.Color <> vbWhite

如何使用 epplus 进行等效操作?

【问题讨论】:

  • excelSheet.Cells(row,Column).Interior.Color。是一个 RGB 整数。

标签: c# excel wpf epplus


【解决方案1】:

也许这会帮助你更深入地了解它:

在 EPPlus 中,您使用富文本,类似这样(代码未经测试)

if (dataSheet.Cells[1, 1].IsRichText)
{
var x = dataSheet.Cells[1, 1].RichText;
foreach (var g in x) // you will only need the first i think
{
if (g.Color == System.Drawing.Color.White)
{
// Do something
}
}
}

【讨论】:

    猜你喜欢
    • 2019-01-05
    • 1970-01-01
    • 1970-01-01
    • 2019-02-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-17
    相关资源
    最近更新 更多