diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java b/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java index 29a46c5d3..999fa287d 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java @@ -540,6 +540,11 @@ public class HSSFCell implements Cell { setCellType(CELL_TYPE_BLANK, false, row, col, styleIndex); return; } + + if(hvalue.length() > SpreadsheetVersion.EXCEL97.getMaxTextLength()){ + throw new IllegalArgumentException("The maximum length of cell contents (text) is 32,767 characters"); + } + if (_cellType == CELL_TYPE_FORMULA) { // Set the 'pre-evaluated result' for the formula // note - formulas do not preserve text formatting. diff --git a/src/java/org/apache/poi/ss/SpreadsheetVersion.java b/src/java/org/apache/poi/ss/SpreadsheetVersion.java index 316e5af06..d4edaec53 100755 --- a/src/java/org/apache/poi/ss/SpreadsheetVersion.java +++ b/src/java/org/apache/poi/ss/SpreadsheetVersion.java @@ -36,9 +36,11 @@ public enum SpreadsheetVersion { *
  • The total number of available rows is 64k (2^16)
  • *
  • The maximum number of arguments to a function is 30
  • *
  • Number of conditional format conditions on a cell is 3
  • + *
  • Length of text cell contents is unlimited
  • + *
  • Length of text cell contents is 32767
  • * */ - EXCEL97(0x10000, 0x0100, 30, 3), + EXCEL97(0x10000, 0x0100, 30, 3, 32767), /** * Excel2007 @@ -49,21 +51,24 @@ public enum SpreadsheetVersion { *
  • The maximum number of arguments to a function is 255
  • *
  • Number of conditional format conditions on a cell is unlimited * (actually limited by available memory in Excel)
  • + *
  • Length of text cell contents is unlimited
  • *