add a check to prevent NPE in HSSFSheet.autoSizeColumn(). See Bug 44246

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@613396 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yegor Kozlov 2008-01-19 14:28:10 +00:00
parent 47f369643a
commit f6cd038ce3

View File

@ -1748,7 +1748,7 @@ public class HSSFSheet
} else if (cell.getCellType() == HSSFCell.CELL_TYPE_BOOLEAN) { } else if (cell.getCellType() == HSSFCell.CELL_TYPE_BOOLEAN) {
sval = String.valueOf(cell.getBooleanCellValue()); sval = String.valueOf(cell.getBooleanCellValue());
} }
if(sval != null) {
String txt = sval + defaultChar; String txt = sval + defaultChar;
str = new AttributedString(txt); str = new AttributedString(txt);
copyAttributes(font, str, 0, txt.length()); copyAttributes(font, str, 0, txt.length());
@ -1771,6 +1771,7 @@ public class HSSFSheet
width = Math.max(width, layout.getBounds().getWidth() / defaultCharWidth); width = Math.max(width, layout.getBounds().getWidth() / defaultCharWidth);
} }
} }
}
if (width != -1) { if (width != -1) {
if (width > Short.MAX_VALUE) { //width can be bigger that Short.MAX_VALUE! if (width > Short.MAX_VALUE) { //width can be bigger that Short.MAX_VALUE!