]> source.dussan.org Git - poi.git/commitdiff
Fixed XSSFCell to correctly parse column indexes greater than 702 (ZZ), see Bugzilla...
authorYegor Kozlov <yegor@apache.org>
Wed, 5 Aug 2009 17:02:04 +0000 (17:02 +0000)
committerYegor Kozlov <yegor@apache.org>
Wed, 5 Aug 2009 17:02:04 +0000 (17:02 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@801305 13f79535-47bb-0310-9956-ffa450edef68

src/documentation/content/xdocs/status.xml
src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java
src/testcases/org/apache/poi/ss/usermodel/BaseTestRow.java

index af9bb5a6b3b04bd35bfc08a8fe9c011c99ab2397..af0d90c143a211df8ea2a46278248dc7824f6ed3 100644 (file)
@@ -33,6 +33,7 @@
 
     <changes>
         <release version="3.5-beta7" date="2009-??-??">
+           <action dev="POI-DEVELOPERS" type="fix">47606 - Fixed  XSSFCell to correctly parse column indexes greater than 702 (ZZ)</action>
            <action dev="POI-DEVELOPERS" type="fix">47598 - Improved formula evaluator number comparison</action>
            <action dev="POI-DEVELOPERS" type="fix">47571 - Fixed XWPFWordExtractor to extract inserted/deleted text</action>
            <action dev="POI-DEVELOPERS" type="fix">47548 - Fixed RecordFactoryInputStream to properly read continued DrawingRecords</action>
index e817553a4c90fd2aec0cec4f63b237bc5e9b4234..f6615b73e8649cc69939d235516dff925e4038ba 100644 (file)
@@ -97,7 +97,7 @@ public final class XSSFCell implements Cell {
         this.cell = cell;
         this.row = row;
         if (cell.getR() != null) {
-            this.cellNum = parseCellNum(cell.getR());
+            this.cellNum = new CellReference(cell.getR()).getCol();
         }
         this.sharedStringSource = row.getSheet().getWorkbook().getSharedStringSource();
         this.stylesSource = row.getSheet().getWorkbook().getStylesSource();
@@ -647,21 +647,6 @@ public final class XSSFCell implements Cell {
         cell.setR(ref);
     }
 
-    /**
-     * Converts A1 style reference into 0-based column index
-     *
-     * @param r an A1 style reference to the location of this cell
-     * @return 0-based column index
-     */
-    protected static short parseCellNum(String r) {
-        r = r.split("\\d+")[0];
-        if (r.length() == 1) {
-            return (short) (r.charAt(0) - 'A');
-        } else {
-            return (short) (r.charAt(1) - 'A' + 26 * (r.charAt(0) - '@'));
-        }
-    }
-
     /**
      * Set the cells type (numeric, formula or string)
      *
index 3c162d7762ed320f95092f90a4e7015ab429201b..8124ede7bf78c686dd2f5f8369458cb39ad9e5cc 100755 (executable)
@@ -160,8 +160,6 @@ public abstract class BaseTestRow extends TestCase {
             assertTrue(e.getMessage().startsWith("Invalid column index (-1)"));
         }
 
-        row.createCell(maxCellNum);
-
         //Test high cell bound
         try {
             Cell cell = row.createCell(maxCellNum + 1);
@@ -170,6 +168,19 @@ public abstract class BaseTestRow extends TestCase {
             // expected during successful test
             assertTrue(e.getMessage().startsWith("Invalid column index ("+(maxCellNum+1)+")"));
         }
+        for(int i=0; i < maxCellNum; i++){
+            Cell cell = row.createCell(i);
+        }
+        assertEquals(maxCellNum, row.getPhysicalNumberOfCells());
+        workbook = getTestDataProvider().writeOutAndReadBack(workbook);
+        sheet = workbook.getSheetAt(0);
+        row = sheet.getRow(0);
+        assertEquals(maxCellNum, row.getPhysicalNumberOfCells());
+        for(int i=0; i < maxCellNum; i++){
+            Cell cell = row.getCell(i);
+            assertEquals(i, cell.getColumnIndex());
+        }
+
     }
 
     /**