I checked the jxl api to check what the getContent() method returns for an empty cell , but it doesn't explicitly indicate what happens !
ref # : http://jexcelapi.sourceforge.net/resources/javadocs/2_6/docs/jxl/Cell.html#getContents%28%29
Can anyone indicate what happens when getContent() is called on a cell which is empty ?
It returns a String of length 0. This is easily tested on a row like so
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");
}
}
如果以上不起作用,请尝试以下命令:
string.isEmpty();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.