【问题标题】:NPOI how to read richtext from cellNPOI如何从单元格中读取富文本
【发布时间】:2020-06-26 18:07:28
【问题描述】:

我必须阅读带有 NPOI 的 XLSX。在我的 xlsx 中,有些单元格有粗体字,有没有办法使用 NPOI 找到这些字词?

谢谢

【问题讨论】:

  • 你好,你能提供一些你试过的源代码吗?您是否遇到任何异常,或者您是否使用了一些文档作为参考?

标签: c# .net excel npoi


【解决方案1】:

我发现的唯一方法是循环富文本的每个字符

XSSFRichTextString s = (XSSFRichTextString)c.RichStringCellValue;

for (int t = 0; t < s.Length; t++)
{
    var myfont = s.GetFontAtIndex(t);
    if (myfont != null && myfont.IsBold)
        boldCharactersIndex.Add(t); // boldCharactersIndex is a list of indexes with bold chars
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-22
    • 2017-07-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多