【问题标题】:Excel Interop - get table style colorsExcel Interop - 获取表格样式颜色
【发布时间】:2022-12-03 17:11:25
【问题描述】:

我使用 Excel Interop,我尝试从特定的表格样式中获取行的颜色。

我得到这样的表格样式名称:

var TableStyle = table.TableStyle.Name.ToString();

但是我不知道如何从已知样式中获取颜色。

【问题讨论】:

    标签: excel office-interop com-interop


    【解决方案1】:

    我解决了我的问题。

    如果将来有人会有类似的。

    您可以通过这种方式访问​​表:

    var tse = table.TableStyle.TableStyleElements;
    double rs1 = ((TableStyleElement)tse[5]).Interior.Color;
    double rs2 = ((TableStyleElement)tse[6]).Interior.Color;
    

    当 tse 的索引是枚举时: https://learn.microsoft.com/en-us/dotnet/api/microsoft.office.interop.excel.xltablestyleelementtype?view=excel-pia

    但如果您需要创建新样式,则应复制现有样式并进行编辑。 https://learn.microsoft.com/en-us/previous-versions/office/developer/office-2010/hh273483(v=office.14)?redirectedfrom=MSDN

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-06-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-14
      • 1970-01-01
      • 2010-11-03
      • 1970-01-01
      • 2018-05-05
      相关资源
      最近更新 更多