<!-- Don't forget to update status.xml too! -->
<release version="3.5-beta6" date="2009-??-??">
+ <action dev="POI-DEVELOPERS" type="fix">46832 - Allow merged regions with columns greater than 255 or rows bigger than 65536 in XSSF</action>
<action dev="POI-DEVELOPERS" type="fix">46951 - Fixed formula parser to better handle range operators and whole row/column refs.</action>
<action dev="POI-DEVELOPERS" type="fix">46948 - Fixed evaluation of range operator to allow for area-ref operands</action>
<action dev="POI-DEVELOPERS" type="fix">46918 - Fixed ExtendedPivotTableViewFieldsRecord(SXVDEX) to allow shorter format</action>
<!-- Don't forget to update changes.xml too! -->
<changes>
<release version="3.5-beta6" date="2009-??-??">
+ <action dev="POI-DEVELOPERS" type="fix">46832 - Allow merged regions with columns greater than 255 or rows bigger than 65536 in XSSF</action>
<action dev="POI-DEVELOPERS" type="fix">46951 - Fixed formula parser to better handle range operators and whole row/column refs.</action>
<action dev="POI-DEVELOPERS" type="fix">46948 - Fixed evaluation of range operator to allow for area-ref operands</action>
<action dev="POI-DEVELOPERS" type="fix">46918 - Fixed ExtendedPivotTableViewFieldsRecord(SXVDEX) to allow shorter format</action>
private static final int OPTION_BITS_ALWAYS_SET = 0x0100;
private static final int DEFAULT_HEIGHT_BIT = 0x8000;
- /** The maximum row number that excel can handle (zero based) ie 65536 rows is
- * max number of rows.
- */
- public final static int MAX_ROW_NUMBER = 65535;
-
private int field_1_row_number;
private int field_2_first_col;
private int field_3_last_col; // plus 1
import org.apache.poi.hssf.record.TableRecord;
import org.apache.poi.hssf.record.UnknownRecord;
import org.apache.poi.hssf.record.formula.FormulaShifter;
+import org.apache.poi.ss.SpreadsheetVersion;
/**
*
}
public RowRecord getRow(int rowIndex) {
- if (rowIndex < 0 || rowIndex > 65535) {
- throw new IllegalArgumentException("The row number must be between 0 and 65535");
+ int maxrow = SpreadsheetVersion.EXCEL97.getLastRowIndex();
+ if (rowIndex < 0 || rowIndex > maxrow) {
+ throw new IllegalArgumentException("The row number must be between 0 and " + maxrow);
}
return _rowRecords.get(new Integer(rowIndex));
}
import org.apache.poi.util.BitFieldFactory;
import org.apache.poi.util.LittleEndianInput;
import org.apache.poi.util.LittleEndianOutput;
+import org.apache.poi.ss.SpreadsheetVersion;
/**
* ReferencePtgBase - handles references (such as A1, A2, IA4)
*/
public abstract class RefPtgBase extends OperandPtg {
- private final static int MAX_ROW_NUMBER = 65536;
+ private final static int MAX_ROW_NUMBER = SpreadsheetVersion.EXCEL97.getMaxRows();
/** The row index - zero based unsigned 16 bit value */
private int field_1_row;
}
/**
- * @return the row number as an int, between 0 and 65535
+ * @return the row number as an int
*/
public final int getRow() {
return field_1_row;
import org.apache.poi.ss.usermodel.Hyperlink;
import org.apache.poi.ss.usermodel.RichTextString;
import org.apache.poi.ss.formula.FormulaType;
+import org.apache.poi.ss.SpreadsheetVersion;
/**
* High level representation of a cell in a row of a spreadsheet.
/**
* The maximum number of columns in BIFF8
*/
- public static final int LAST_COLUMN_NUMBER = 255; // 2^8 - 1
- private static final String LAST_COLUMN_NAME = "IV";
+ public static final int LAST_COLUMN_NUMBER = SpreadsheetVersion.EXCEL97.getLastColumnIndex(); // 2^8 - 1
+ private static final String LAST_COLUMN_NAME = SpreadsheetVersion.EXCEL97.getLastColumnName();
public final static short ENCODING_UNCHANGED = -1;
public final static short ENCODING_COMPRESSED_UNICODE = 0;
import org.apache.poi.hssf.record.RowRecord;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.SpreadsheetVersion;
/**
* High level representation of a row of a spreadsheet.
* @throws IndexOutOfBoundsException if the row number is not within the range 0-65535.
*/
public void setRowNum(int rowIndex) {
- if ((rowIndex < 0) || (rowIndex > RowRecord.MAX_ROW_NUMBER)) {
+ int maxrow = SpreadsheetVersion.EXCEL97.getLastRowIndex();
+ if ((rowIndex < 0) || (rowIndex > maxrow)) {
throw new IllegalArgumentException("Invalid row number (" + rowIndex
- + ") outside allowable range (0.." + RowRecord.MAX_ROW_NUMBER + ")");
+ + ") outside allowable range (0.." + maxrow + ")");
}
rowNum = rowIndex;
if (row != null) {
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.ss.SpreadsheetVersion;
import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
*/
public int addMergedRegion(CellRangeAddress region)
{
+ region.validate(SpreadsheetVersion.EXCEL97);
return _sheet.addMergedRegion( region.getFirstRow(),
region.getFirstColumn(),
region.getLastRow(),
}
}
}
- if ( endRow == _lastrow || endRow + n > _lastrow ) _lastrow = Math.min( endRow + n, 65535 );
+ if ( endRow == _lastrow || endRow + n > _lastrow ) _lastrow = Math.min( endRow + n, SpreadsheetVersion.EXCEL97.getLastRowIndex() );
if ( startRow == _firstrow || startRow + n < _firstrow ) _firstrow = Math.max( startRow + n, 0 );
// Update any formulas on this sheet that point to
* @param leftmostColumn Left column visible in right pane.
*/
public void createFreezePane(int colSplit, int rowSplit, int leftmostColumn, int topRow) {
- if (colSplit < 0 || colSplit > 255) throw new IllegalArgumentException("Column must be between 0 and 255");
- if (rowSplit < 0 || rowSplit > 65535) throw new IllegalArgumentException("Row must be between 0 and 65535");
+ validateColumn(colSplit);
+ validateRow(rowSplit);
if (leftmostColumn < colSplit) throw new IllegalArgumentException("leftmostColumn parameter must not be less than colSplit parameter");
if (topRow < rowSplit) throw new IllegalArgumentException("topRow parameter must not be less than leftmostColumn parameter");
getSheet().createFreezePane( colSplit, rowSplit, topRow, leftmostColumn );
*/
public void setColumnBreak(int column) {
validateColumn((short)column);
- _sheet.getPageSettings().setColumnBreak((short)column, (short)0, (short)65535);
+ _sheet.getPageSettings().setColumnBreak((short)column, (short)0, (short) SpreadsheetVersion.EXCEL97.getLastRowIndex());
}
/**
* @param row
*/
protected void validateRow(int row) {
- if (row > 65535) throw new IllegalArgumentException("Maximum row number is 65535");
+ int maxrow = SpreadsheetVersion.EXCEL97.getLastRowIndex();
+ if (row > maxrow) throw new IllegalArgumentException("Maximum row number is " + maxrow);
if (row < 0) throw new IllegalArgumentException("Minumum row number is 0");
}
* Runs a bounds check for column numbers
* @param column
*/
- protected void validateColumn(short column) {
- if (column > 255) throw new IllegalArgumentException("Maximum column number is 255");
+ protected void validateColumn(int column) {
+ int maxcol = SpreadsheetVersion.EXCEL97.getLastColumnIndex();
+ if (column > maxcol) throw new IllegalArgumentException("Maximum column number is " + maxcol);
if (column < 0) throw new IllegalArgumentException("Minimum column number is 0");
}
import org.apache.poi.hssf.record.aggregates.ConditionalFormattingTable;\r
import org.apache.poi.ss.util.Region;\r
import org.apache.poi.ss.util.CellRangeAddress;\r
+import org.apache.poi.ss.SpreadsheetVersion;\r
\r
/**\r
* The 'Conditional Formatting' facet of <tt>HSSFSheet</tt>\r
if (regions == null) {\r
throw new IllegalArgumentException("regions must not be null");\r
}\r
- if (cfRules == null) {\r
+ for(CellRangeAddress range : regions) range.validate(SpreadsheetVersion.EXCEL97);\r
+\r
+ if (cfRules == null) {\r
throw new IllegalArgumentException("cfRules must not be null");\r
}\r
if (cfRules.length == 0) {\r
* @author Dragos Buleandra (dragos.buleandra@trade2b.ro)\r
*/\r
public class CellRangeAddress extends org.apache.poi.ss.util.CellRangeAddress {\r
- /*\r
- * TODO - replace org.apache.poi.hssf.util.Region\r
- */\r
- public static final int ENCODED_SIZE = 8;\r
\r
public CellRangeAddress(int firstRow, int lastRow, int firstCol, int lastCol) {\r
super(firstRow, lastRow, firstCol, lastCol);\r
}\r
public CellRangeAddress(RecordInputStream in) {\r
- super(readUShortAndCheck(in), in.readUShort(), in.readUShort(), in.readUShort());\r
- }\r
-\r
- private static int readUShortAndCheck(RecordInputStream in) {\r
- if (in.remaining() < ENCODED_SIZE) {\r
- // Ran out of data\r
- throw new RuntimeException("Ran out of data reading CellRangeAddress");\r
- }\r
- return in.readUShort();\r
+ super(in);\r
}\r
}\r
* discernable to the user. It is not intended to deal with low-level issues like file formats. \r
* <p/>\r
* \r
- * For internal POI use only\r
- * \r
* @author Josh Micich\r
* @author Yegor Kozlov\r
*/\r
package org.apache.poi.ss.util;
+import org.apache.poi.ss.SpreadsheetVersion;
+
import java.util.ArrayList;
import java.util.StringTokenizer;
// C$1:C$65535 or D$1:F$0
// i.e. absolute from 1st row to 0th one
if(topLeft.getRow() == 0 && topLeft.isRowAbsolute() &&
- botRight.getRow() == 65535 && botRight.isRowAbsolute()) {
+ botRight.getRow() == SpreadsheetVersion.EXCEL97.getLastRowIndex() && botRight.isRowAbsolute()) {
return true;
}
return false;
package org.apache.poi.ss.util;
+import org.apache.poi.ss.SpreadsheetVersion;
+
/**
* See OOO documentation: excelfileformat.pdf sec 2.5.14 - 'Cell Range Address'<p/>
*/
public abstract class CellRangeAddressBase {
- /** max 65536 rows in BIFF8 */
- private static final int LAST_ROW_INDEX = 0x00FFFF;
- /** max 256 columns in BIFF8 */
- private static final int LAST_COLUMN_INDEX = 0x00FF;
-
private int _firstRow;
private int _firstCol;
private int _lastRow;
private int _lastCol;
protected CellRangeAddressBase(int firstRow, int lastRow, int firstCol, int lastCol) {
- if(!isValid(firstRow, lastRow, firstCol, lastCol)) {
- throw new IllegalArgumentException("invalid cell range (" + firstRow + ", " + lastRow
- + ", " + firstCol + ", " + lastCol + ")");
- }
_firstRow = firstRow;
- _lastRow =lastRow;
+ _lastRow = lastRow;
_firstCol = firstCol;
_lastCol = lastCol;
}
- private static boolean isValid(int firstRow, int lastRow, int firstColumn, int lastColumn) {
- if(lastRow < 0 || lastRow > LAST_ROW_INDEX) {
- return false;
- }
- if(firstRow < 0 || firstRow > LAST_ROW_INDEX) {
- return false;
- }
-
- if(lastColumn < 0 || lastColumn > LAST_COLUMN_INDEX) {
- return false;
- }
- if(firstColumn < 0 || firstColumn > LAST_COLUMN_INDEX) {
- return false;
- }
- return true;
+
+ /**
+ * Validate the range limits against the supplied version of Excel
+ *
+ * @param ssVersion the version of Excel to validate against
+ * @throws IllegalArgumentException if the range limits are outside of the allowed range
+ */
+ public void validate(SpreadsheetVersion ssVersion) {
+ validateRow(_firstRow, ssVersion);
+ validateRow(_lastRow, ssVersion);
+ validateColumn(_firstCol, ssVersion);
+ validateColumn(_lastCol, ssVersion);
}
-
+ /**
+ * Runs a bounds check for row numbers
+ * @param row
+ */
+ private static void validateRow(int row, SpreadsheetVersion ssVersion) {
+ int maxrow = ssVersion.getLastRowIndex();
+ if (row > maxrow) throw new IllegalArgumentException("Maximum row number is " + maxrow);
+ if (row < 0) throw new IllegalArgumentException("Minumum row number is 0");
+ }
+
+ /**
+ * Runs a bounds check for column numbers
+ * @param column
+ */
+ private static void validateColumn(int column, SpreadsheetVersion ssVersion) {
+ int maxcol = ssVersion.getLastColumnIndex();
+ if (column > maxcol) throw new IllegalArgumentException("Maximum column number is " + maxcol);
+ if (column < 0) throw new IllegalArgumentException("Minimum column number is 0");
+ }
+
- public final boolean isFullColumnRange() {
- return _firstRow == 0 && _lastRow == LAST_ROW_INDEX;
+ //TODO use the correct SpreadsheetVersion
+ public final boolean isFullColumnRange() {
+ return _firstRow == 0 && _lastRow == SpreadsheetVersion.EXCEL97.getLastRowIndex();
}
+ //TODO use the correct SpreadsheetVersion
public final boolean isFullRowRange() {
- return _firstCol == 0 && _lastCol == LAST_COLUMN_INDEX;
+ return _firstCol == 0 && _lastCol == SpreadsheetVersion.EXCEL97.getLastColumnIndex();
}
/**
import java.util.regex.Pattern;
import org.apache.poi.hssf.record.formula.SheetNameFormatter;
+import org.apache.poi.ss.SpreadsheetVersion;
/**
*
* digits or dot. (They can even end in dot).
*/
private static final Pattern NAMED_RANGE_NAME_PATTERN = Pattern.compile("[_A-Za-z][_.A-Za-z0-9]*");
- private static final String BIFF8_LAST_COLUMN = "IV";
+ private static final String BIFF8_LAST_COLUMN = SpreadsheetVersion.EXCEL97.getLastColumnName();
private static final int BIFF8_LAST_COLUMN_TEXT_LEN = BIFF8_LAST_COLUMN.length();
- private static final String BIFF8_LAST_ROW = String.valueOf(0x10000);
+ private static final String BIFF8_LAST_ROW = String.valueOf(SpreadsheetVersion.EXCEL97.getMaxRows());
private static final int BIFF8_LAST_ROW_TEXT_LEN = BIFF8_LAST_ROW.length();
private final int _rowIndex;
import org.apache.poi.ss.formula.FormulaParser;
import org.apache.poi.ss.formula.FormulaType;
import org.apache.poi.ss.formula.FormulaRenderer;
+import org.apache.poi.ss.SpreadsheetVersion;
import org.apache.poi.xssf.model.StylesTable;
import org.apache.poi.xssf.model.SharedStringsTable;
import org.apache.poi.util.POILogger;
public final class XSSFCell implements Cell {
private static POILogger logger = POILogFactory.getLogger(XSSFCell.class);
- private static final String FILE_FORMAT_NAME = "BIFF12";
- /**
- * The maximum number of columns in SpreadsheetML
- */
- public static final int LAST_COLUMN_NUMBER = 16384-1; //2^14-1
- private static final String LAST_COLUMN_NAME = "XFD";
-
private static final String FALSE_AS_STRING = "0";
private static final String TRUE_AS_STRING = "1";
* @throws RuntimeException if the bounds are exceeded.
*/
private static void checkBounds(int cellIndex) {
- if (cellIndex < 0 || cellIndex > LAST_COLUMN_NUMBER) {
+ SpreadsheetVersion v = SpreadsheetVersion.EXCEL2007;
+ int maxcol = SpreadsheetVersion.EXCEL2007.getLastColumnIndex();
+ if (cellIndex < 0 || cellIndex > maxcol) {
throw new IllegalArgumentException("Invalid column index (" + cellIndex
- + "). Allowable column range for " + FILE_FORMAT_NAME + " is (0.."
- + LAST_COLUMN_NUMBER + ") or ('A'..'" + LAST_COLUMN_NAME + "')");
+ + "). Allowable column range for " + v.name() + " is (0.."
+ + maxcol + ") or ('A'..'" + v.getLastColumnName() + "')");
}
}
import org.apache.poi.ss.formula.FormulaParser;
import org.apache.poi.ss.formula.FormulaType;
import org.apache.poi.ss.formula.FormulaRenderer;
+import org.apache.poi.ss.SpreadsheetVersion;
import org.apache.poi.xssf.model.CalculationChain;
import org.apache.poi.hssf.record.formula.Ptg;
import org.apache.poi.hssf.record.formula.FormulaShifter;
public class XSSFRow implements Row, Comparable<XSSFRow> {
private static final POILogger logger = POILogFactory.getLogger(XSSFRow.class);
- private static final String FILE_FORMAT_NAME = "BIFF12";
- /**
- * The maximum number of rows in SpreadsheetML
- */
- public static final int MAX_ROW_NUMBER = 1048575; //2 ^ 20 - 1
-
/**
* the xml bean containing all cell definitions for this row
*/
* Set the row number of this row.
*
* @param rowIndex the row number (0-based)
- * @throws IllegalArgumentException if rowNum < 0 or greater than {@link #MAX_ROW_NUMBER}
+ * @throws IllegalArgumentException if rowNum < 0 or greater than 1048575
*/
public void setRowNum(int rowIndex) {
- if (rowIndex < 0 || rowIndex > MAX_ROW_NUMBER) {
+ int maxrow = SpreadsheetVersion.EXCEL2007.getLastRowIndex();
+ if (rowIndex < 0 || rowIndex > maxrow) {
throw new IllegalArgumentException("Invalid row number (" + rowIndex
- + ") outside allowable range (0.." + MAX_ROW_NUMBER + ")");
+ + ") outside allowable range (0.." + maxrow + ")");
}
row.setR(rowIndex + 1);
}
import org.apache.poi.ss.formula.FormulaParser;
import org.apache.poi.ss.formula.FormulaType;
import org.apache.poi.ss.formula.FormulaRenderer;
+import org.apache.poi.ss.SpreadsheetVersion;
import org.apache.poi.xssf.model.CommentsTable;
import org.apache.poi.xssf.model.CalculationChain;
import org.apache.poi.xssf.usermodel.helpers.ColumnHelper;
* @return index of this region
*/
public int addMergedRegion(CellRangeAddress cra) {
+ cra.validate(SpreadsheetVersion.EXCEL2007);
+
CTMergeCells ctMergeCells = worksheet.isSetMergeCells() ? worksheet.getMergeCells() : worksheet.addNewMergeCells();
CTMergeCell ctMergeCell = ctMergeCells.addNewMergeCell();
ctMergeCell.setRef(cra.formatAsString());
CTMergeCell ctMergeCell = ctMergeCells.getMergeCellArray(index);
String ref = ctMergeCell.getRef();
- CellReference cell1 = new CellReference(ref.substring(0, ref.indexOf(":")));
- CellReference cell2 = new CellReference(ref.substring(ref.indexOf(":") + 1));
- return new CellRangeAddress(cell1.getRow(), cell2.getRow(), cell1.getCol(), cell2.getCol());
+ return CellRangeAddress.valueOf(ref);
}
/**
package org.apache.poi.xssf;\r
\r
import org.apache.poi.ss.ITestDataProvider;\r
+import org.apache.poi.ss.SpreadsheetVersion;\r
import org.apache.poi.ss.usermodel.Workbook;\r
import org.apache.poi.xssf.usermodel.XSSFWorkbook;\r
import org.apache.poi.hssf.HSSFTestDataSamples;\r
return HSSFTestDataSamples.getTestDataFileContent(fileName);\r
}\r
\r
+ public SpreadsheetVersion getSpreadsheetVersion(){\r
+ return SpreadsheetVersion.EXCEL2007;\r
+ }\r
+\r
private XSSFITestDataProvider(){}\r
private static XSSFITestDataProvider inst = new XSSFITestDataProvider();\r
public static XSSFITestDataProvider getInstance(){\r
import junit.framework.TestCase;
import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.SpreadsheetVersion;
import org.apache.poi.xssf.model.SharedStringsTable;
import org.apache.poi.xssf.XSSFTestDataSamples;
import org.apache.poi.xssf.XSSFITestDataProvider;
}
public void testRowBounds() {
- baseTestRowBounds(XSSFRow.MAX_ROW_NUMBER);
+ baseTestRowBounds(SpreadsheetVersion.EXCEL2007.getLastRowIndex());
}
public void testCellBounds() {
- baseTestCellBounds(XSSFCell.LAST_COLUMN_NUMBER);
+ baseTestCellBounds(SpreadsheetVersion.EXCEL2007.getLastColumnIndex());
}
}
\r
import org.apache.poi.hssf.usermodel.HSSFWorkbook;\r
import org.apache.poi.ss.ITestDataProvider;\r
+import org.apache.poi.ss.SpreadsheetVersion;\r
import org.apache.poi.ss.usermodel.Workbook;\r
\r
/**\r
return HSSFTestDataSamples.getTestDataFileContent(fileName);\r
}\r
\r
+ public SpreadsheetVersion getSpreadsheetVersion(){\r
+ return SpreadsheetVersion.EXCEL2007;\r
+ }\r
+\r
private HSSFITestDataProvider(){}\r
private static HSSFITestDataProvider inst = new HSSFITestDataProvider();\r
public static HSSFITestDataProvider getInstance(){\r
import org.apache.poi.hssf.record.BlankRecord;
import org.apache.poi.hssf.record.RowRecord;
import org.apache.poi.ss.usermodel.BaseTestRow;
+import org.apache.poi.ss.SpreadsheetVersion;
/**
* Test HSSFRow is okay.
}
public void testRowBounds() {
- baseTestRowBounds(RowRecord.MAX_ROW_NUMBER);
+ baseTestRowBounds(SpreadsheetVersion.EXCEL97.getLastRowIndex());
}
public void testCellBounds() {
- baseTestCellBounds(HSSFCell.LAST_COLUMN_NUMBER);
+ baseTestCellBounds(SpreadsheetVersion.EXCEL97.getLastColumnIndex());
}
public void testLastAndFirstColumns_bug46654() {
package org.apache.poi.hssf.usermodel;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import junit.framework.AssertionFailedError;
-import junit.framework.TestCase;
import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.hssf.HSSFITestDataProvider;
import org.apache.poi.hssf.model.Sheet;
import org.apache.poi.hssf.model.DrawingManager2;
import org.apache.poi.hssf.record.*;
-import org.apache.poi.ss.util.Region;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.usermodel.BaseTestSheet;
import org.apache.poi.ddf.EscherDgRecord;
* @return an open <tt>InputStream</tt> for the specified sample file\r
*/\r
byte[] getTestDataFileContent(String fileName);\r
+\r
+ SpreadsheetVersion getSpreadsheetVersion();\r
}\r
import junit.framework.TestCase;
import org.apache.poi.ss.ITestDataProvider;
+import org.apache.poi.ss.SpreadsheetVersion;
import org.apache.poi.ss.util.CellRangeAddress;
import java.util.Iterator;
assertEquals(3, sheetP.getPrintSetup().getCopies());
}
+ /**
+ * Test adding merged regions. If the region's bounds are outside of the allowed range
+ * then an IllegalArgumentException should be thrown
+ *
+ */
+ public void testAddMerged() {
+ Workbook wb = getTestDataProvider().createWorkbook();
+ Sheet sheet = wb.createSheet();
+ assertEquals(0, sheet.getNumMergedRegions());
+ SpreadsheetVersion ssVersion = getTestDataProvider().getSpreadsheetVersion();
+
+ CellRangeAddress region = new CellRangeAddress(0, 1, 0, 1);
+ sheet.addMergedRegion(region);
+ assertEquals(1, sheet.getNumMergedRegions());
+
+ try {
+ region = new CellRangeAddress(-1, -1, -1, -1);
+ sheet.addMergedRegion(region);
+ fail("Expected exception");
+ } catch (IllegalArgumentException e){
+ ;
+ }
+ try {
+ region = new CellRangeAddress(0, 0, 0, ssVersion.getLastColumnIndex() + 1);
+ sheet.addMergedRegion(region);
+ fail("Expected exception");
+ } catch (IllegalArgumentException e){
+ ;
+ }
+ try {
+ region = new CellRangeAddress(0, ssVersion.getLastRowIndex() + 1, 0, 1);
+ sheet.addMergedRegion(region);
+ fail("Expected exception");
+ } catch (IllegalArgumentException e){
+ ;
+ }
+ assertEquals(1, sheet.getNumMergedRegions());
+
+ }
+
/**
* When removing one merged region, it would break
*
assertEquals("sheet3", workbook.getSheetName(0));\r
workbook.removeSheetAt(0);\r
assertEquals(0, workbook.getNumberOfSheets());\r
+\r
+ //re-create the sheets\r
+ workbook.createSheet("sheet1");\r
+ workbook.createSheet("sheet2");\r
+ workbook.createSheet("sheet3");\r
+ assertEquals(3, workbook.getNumberOfSheets());\r
}\r
\r
public void testDefaultValues() {\r