【发布时间】:2020-06-26 18:07:28
【问题描述】:
我必须阅读带有 NPOI 的 XLSX。在我的 xlsx 中,有些单元格有粗体字,有没有办法使用 NPOI 找到这些字词?
谢谢
【问题讨论】:
-
你好,你能提供一些你试过的源代码吗?您是否遇到任何异常,或者您是否使用了一些文档作为参考?
我必须阅读带有 NPOI 的 XLSX。在我的 xlsx 中,有些单元格有粗体字,有没有办法使用 NPOI 找到这些字词?
谢谢
【问题讨论】:
我发现的唯一方法是循环富文本的每个字符
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
}
【讨论】: