在我的Java代码中,我试图使用Apache-POI在.xlsx文件中的单元格内提取一些字体信息。我只需要检索string-cell的哪些子字符串为粗体。
问题是我的代码仅在单元格不是以粗体字开头时才起作用。
我使用以下(简化)代码:
XSSFRichTextString formatted = (XSSFRichTextString)cell.getRichStringCellValue();
formatted.getFontAtIndex(0).getBold(); //line 1
formatted.getFontAtIndex(22).getBold(); //line 2
我正在读取的单元格内容如下: “ 第一字符串第二字符串第三字符串 ecc ...”
22是第3字符串开始的索引。 第1行返回(意外)为false,而第2行返回(预期)为true。
我想念什么?