Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/304.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用ApachePOI将单元格设置为富文本_Java_Excel_Grails_Apache Poi - Fatal编程技术网

Java 使用ApachePOI将单元格设置为富文本

Java 使用ApachePOI将单元格设置为富文本,java,excel,grails,apache-poi,Java,Excel,Grails,Apache Poi,我有一个使用ApachePOI的Grails应用程序,我正在尝试将富文本附加到单元格中。当我试图用特定的XSSFFont附加文本时,我得到一个错误 - IndexOutOfBoundsException occurred Stacktrace follows: java.lang.IndexOutOfBoundsException at org.apache.poi.xssf.usermodel.XSSFRichTextString.setStylesTableReference(XSSFRic

我有一个使用ApachePOI的Grails应用程序,我正在尝试将富文本附加到单元格中。当我试图用特定的XSSFFont附加文本时,我得到一个错误

- IndexOutOfBoundsException occurred
Stacktrace follows:
java.lang.IndexOutOfBoundsException
at org.apache.poi.xssf.usermodel.XSSFRichTextString.setStylesTableReference(XSSFRichTextString.java:439)
at org.apache.poi.xssf.usermodel.XSSFCell.setCellValue(XSSFCell.java:344)
这是我用来附加富文本的代码:

private def addStringToCell(XSSFCell cell, String text, XSSFFont font) {
    XSSFRichTextString richText = cell.getRichStringCellValue()
    if (font == null) {
        richText.append(text)
    } else {
        richText.append(text, font)   <- i only get the exception if this happens
    }
    cell.setCellValue(richText)   <- exception occurs here
}
private def addStringToCell(XSSFCell单元格、字符串文本、XSSFFont字体){
XSSFRichTextString richText=cell.getRichStringCellValue()
如果(字体==null){
追加(文本)
}否则{

追加(文本,字体)这是写入新工作簿还是要添加到现有工作簿?您使用的是什么版本的Apache POI?我正在使用excel模板生成新的excel文件。此用例是指我已将文本添加到单元格,并且需要将其他彩色文本添加到该单元格。POI版本:3.7是否尝试升级到POI 3.10 beta 2(最新版本),看看它是否是一个已经修复的bug?