看来我是有点咸菜,我读到有HSSF阅读的XLS文件的各种主题,但我似乎无法找到好的XSSF教程和这真的很难,因为他们有不同的语句。 我的代码应该读第2行2列,但我得到一个“getContents()是未定义的类型XSSFComment”错误
我的代码都类似:
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public class parsing{
public static void main(String[] args) throws IOException {
InputStream ExcelFileToRead = new FileInputStream("C:/test.xlsx");
XSSFWorkbook wb = new XSSFWorkbook(ExcelFileToRead);
XSSFSheet sh = wb.getSheetAt(0);
System.out.println(sh.getCellComment(1,1).getContents());
}
}
错误:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The method getContents() is undefined for the type XSSFComment
at parsing.main(parsing.java:18)