我检查了 jxl api 以检查 getContent() 方法为空单元格返回的内容,但它没有明确指示会发生什么!
引用号:http://jexcelapi.sourceforge.net/resources/javadocs/2_6/docs/jxl/Cell.html#getContents%28%29
任何人都可以指示在空单元格上调用 getContent() 时会发生什么吗?
最佳答案
它返回一个长度为 0 的字符串。这很容易在像这样的行上进行测试
Cell[] cells = sheet.getRow(10) // selecting row 10 from the current sheet
for (Cell cell : cells) {
String contents = cell.getContents();
if (contents == null) {
System.out.println("Will not print");
} else if (contents.length() == 0) {
System.out.println("This will print for a blank cell");
} else {
System.out.println("This cell is not empty");
}
}
关于java - 使用jxl读取excel文件时如何检查单元格是否为空白,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9531501/