Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/26.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
Excel ApachePOI:空行中空单元格中的注释_Excel_Apache Poi_Xssf_Hssf - Fatal编程技术网

Excel ApachePOI:空行中空单元格中的注释

Excel ApachePOI:空行中空单元格中的注释,excel,apache-poi,xssf,hssf,Excel,Apache Poi,Xssf,Hssf,我对ApachePOI有一个大问题 A B C D 1 text text text text 2 comment 3 text text text text 在本例中,第2行为空,C2没有文本,只有注释 如果我想得到第2行,POI将返回null 如何从空行中的空单元格中获取注释?要获取任意注释,而不直接通过单元格,可以使用 根据您的示例,要获取C2

我对ApachePOI有一个大问题

    A       B       C       D
1   text    text    text    text
2                   comment           
3   text    text    text    text
在本例中,第2行为空,C2没有文本,只有注释

如果我想得到第2行,POI将返回null


如何从空行中的空单元格中获取注释?

要获取任意注释,而不直接通过单元格,可以使用

根据您的示例,要获取C2中的注释,请执行以下操作:

CellReference ref = new CellReference("C2")
Comment commentC2 = sheet.getCellComment(ref.getRow(), ref.getCol());

嘿:),谢谢你的回答。它适用于评论,但如果我有一个只有cellstyle的空单元格,我该怎么办?也有解决方案吗?如果一个单元格被显式地设置样式,它将作为空白类型的单元格返回。如果它只是隐式样式,您需要从行中获取默认样式不幸的是没有…行没有样式,单元格也不是空的对不起,问题是我使用了样式表(来自样式和格式)。。。XSSFSheet不会从标准样式表中读取foregroundcolor