You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2009/03/11 03:55:12 UTC

DO NOT REPLY [Bug 46832] New: Cannot create Merged Regions when column is bigger that 255 or row bigger than 65536

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.prokein@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-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 46832] XSSF - Cannot create Merged Regions when column is bigger than 255 or row bigger than 65536

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=46832


jurgen.prokein@str.com.au changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Cannot create Merged        |XSSF - Cannot create Merged
                   |Regions when column is      |Regions when column is
                   |bigger that 255 or row      |bigger than 255 or row
                   |bigger than 65536           |bigger than 65536




-- 
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-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 46832] XSSF - Cannot create Merged Regions when column is bigger than 255 or row bigger than 65536

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=46832


Yegor Kozlov <ye...@dinom.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




--- Comment #1 from Yegor Kozlov <ye...@dinom.ru>  2009-04-06 08:14:34 PST ---
Fixed in r762372 ( https://svn.apache.org/viewcvs.cgi?view=rev&rev=762372 )
The CellRangeAddress constructor now allows columns greater than 255 and rows
greater than 65535. No changes in user code are required. I removed validation
from the constructor of CellRangeAddress and moved it to the consumer method
sheet.addMergedRegion. This way the grid limits can be gracefully handled
without subclassing.

Regards,
Yegor

-- 
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-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org