get mad and throw a runtime error if users specify columns > 255
(more than Excel will allow) PR: Obtained from: Submitted by: Reviewed by: git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@352821 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
dced0383e1
commit
50609a09c9
@ -182,6 +182,7 @@ public class HSSFCell
|
|||||||
//protected HSSFCell(Workbook book, Sheet sheet, short row, short col)
|
//protected HSSFCell(Workbook book, Sheet sheet, short row, short col)
|
||||||
protected HSSFCell(Workbook book, Sheet sheet, int row, short col)
|
protected HSSFCell(Workbook book, Sheet sheet, int row, short col)
|
||||||
{
|
{
|
||||||
|
checkBounds(col);
|
||||||
cellNum = col;
|
cellNum = col;
|
||||||
this.row = row;
|
this.row = row;
|
||||||
cellStyle = null;
|
cellStyle = null;
|
||||||
@ -221,6 +222,7 @@ public class HSSFCell
|
|||||||
protected HSSFCell(Workbook book, Sheet sheet, int row, short col,
|
protected HSSFCell(Workbook book, Sheet sheet, int row, short col,
|
||||||
int type)
|
int type)
|
||||||
{
|
{
|
||||||
|
checkBounds(col);
|
||||||
cellNum = col;
|
cellNum = col;
|
||||||
this.row = row;
|
this.row = row;
|
||||||
cellType = type;
|
cellType = type;
|
||||||
@ -953,4 +955,14 @@ public class HSSFCell
|
|||||||
{
|
{
|
||||||
return record;
|
return record;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws RuntimeException if the bounds are exceeded.
|
||||||
|
*/
|
||||||
|
private void checkBounds(int cellNum) {
|
||||||
|
if (cellNum > 255) {
|
||||||
|
throw new RuntimeException("You cannot have more than 255 columns "+
|
||||||
|
"in a given row (IV). Because Excel can't handle it");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user