首页 > 解决方案 > 如何使用具有相同样式和字体的apache POI在网页中显示excel表?

问题描述

我尝试使用RichTextString来获取单个字符的字体,但它仅适用于应用了至少一种不同样式的单元格。在整个单元格中应用相同样式的情况下:

font1 = workbook.getFontAt(richString.getFontAtIndex(i))

在这里,richString.getFontAtIndex(i)返回 0,因此整个字体对象变为空。

标签: htmlexcelapacheapache-poi

解决方案


  if(richString.getFontAtIndex(i)==0){
            font = workbook.getFontAt(cs.getFontIndex());
            font1 = workbook.getFontAt(cs.getFontIndex());     
   } else {
 font = workbook.getFontAt(richString.getFontAtIndex(i))
  font1 = workbook.getFontAt(richString.getFontAtIndex(i))
}

推荐阅读