https://issues.apache.org/bugzilla/show_bug.cgi?id=46832
Summary: Cannot create Merged Regions when column is bigger that 255 or row bigger than 65536 Product: POI Version: 3.5-dev Platform: PC OS/Version: Windows Vista Status: NEW Severity: major Priority: P2 Component: XSSF AssignedTo: dev@poi.apache.org ReportedBy: jurgen.prok...@str.com.au When creating XSSFSheets, it is not possible to ctreate merged regions beyond the 255 column or 65536 row (HSSF) limits. Calling sheet.addMergedRegion() requires a parameter of org.apache.poi.ss.util.CellRangeAddress. This class (CellRangeAddress) calls super() (CellRangeAddressBase), which throws an IllegalArgumentException "invalid cell range" if the column is bigger than 255 or the row is bigger than 65536. CellRangeAddressBase is an abstract base class and should not impose this restriction on actual implementation classes, e.g. there should be a HSSFCellRangeAddress (with its specific limits) and a XSSFCellRangeAddress (with its specific limits), but those classes do not exist (yet?) in poi-3.5-beta5. To reproduce run the following code: final int NUM_COLUMNS = 300; final String output = "MergedRegions.xlsx"; final int columnSpan = 5; XSSFWorkbook wb = new XSSFWorkbook(); XSSFSheet sheet = wb.createSheet("sheet1"); // Create two rows. XSSFRow firstRow = sheet.createRow((short)0); XSSFRow secondRow = sheet.createRow((short)1); XSSFCellStyle centeredStyle = wb.createCellStyle(); centeredStyle.setAlignment(HorizontalAlignment.CENTER); // Create NUM_COLUMNS columns. for (int column = 0; column < NUM_COLUMNS; column++) { // Create a new cell in secondRow. secondRow.createCell(column).setCellValue(column); if (column % columnSpan == 0) { // Create a new cell in firstRow spanning over columnSpan cells. short colFrom = (short)column; short colTo = (short)(colFrom + columnSpan - 1); Cell cell = firstRow.createCell(column); cell.setCellValue("Heading for columns "+colFrom+" to "+colTo); cell.setCellStyle(centeredStyle); sheet.addMergedRegion(new CellRangeAddress(0,0,colFrom,colTo)); } } FileOutputStream fileOut = new FileOutputStream(output); wb.write(fileOut); fileOut.close(); -- Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org For additional commands, e-mail: dev-h...@poi.apache.org