poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ye...@apache.org
Subject svn commit: r657355 - in /poi/trunk/src: documentation/content/xdocs/ documentation/content/xdocs/hssf/ java/org/apache/poi/hssf/usermodel/ testcases/org/apache/poi/hssf/usermodel/
Date Sat, 17 May 2008 14:00:31 GMT
Author: yegor
Date: Sat May 17 07:00:30 2008
New Revision: 657355

URL: http://svn.apache.org/viewvc?rev=657355&view=rev
Log:
added HSSFName.isDeleted() to check if the name points to cell that no longer exists

Modified:
    poi/trunk/src/documentation/content/xdocs/changes.xml
    poi/trunk/src/documentation/content/xdocs/hssf/quick-guide.xml
    poi/trunk/src/documentation/content/xdocs/status.xml
    poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFName.java
    poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestNamedRange.java

Modified: poi/trunk/src/documentation/content/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/changes.xml?rev=657355&r1=657354&r2=657355&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/changes.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/changes.xml Sat May 17 07:00:30 2008
@@ -37,6 +37,7 @@
 
 		<!-- Don't forget to update status.xml too! -->
         <release version="3.1-beta2" date="2008-05-??">
+           <action dev="POI-DEVELOPERS" type="fix">24207 - added HSSFName.isDeleted()
to check if the name points to cell that no longer exists</action>
            <action dev="POI-DEVELOPERS" type="fix">40414 - fixed selected/active sheet
after removing sheet from workbook</action>
            <action dev="POI-DEVELOPERS" type="fix">44523 - fixed workbook sheet selection
and focus</action>
            <action dev="POI-DEVELOPERS" type="fix">45000 - Fixed NPE in ListLevel when
numberText is null</action>

Modified: poi/trunk/src/documentation/content/xdocs/hssf/quick-guide.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/hssf/quick-guide.xml?rev=657355&r1=657354&r2=657355&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/hssf/quick-guide.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/hssf/quick-guide.xml Sat May 17 07:00:30 2008
@@ -1225,7 +1225,19 @@
             // Do something with this corner cell
         }
     }
-            </source>
+          </source>
+          <p>
+            Note, when a cell is deleted, Excel does not delete the attached named range.

+            As result, workbook can contain named ranges that point to cells that no longer
exist.
+            You should check the validity of a reference before constructing AreaReference
 
+          </p>
+          <source>
+    if(hssfName.isDeleted()){
+      //named range points to a deleted cell. 
+    } else {
+      AreaReference ref = new AreaReference(hssfName.getReference());
+    }
+          </source>
         </section>
         <anchor id="CellComments"/>
         <section><title>Cell Comments</title>

Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=657355&r1=657354&r2=657355&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Sat May 17 07:00:30 2008
@@ -34,6 +34,7 @@
 	<!-- Don't forget to update changes.xml too! -->
     <changes>
         <release version="3.1-beta2" date="2008-05-??">
+           <action dev="POI-DEVELOPERS" type="fix">24207 - added HSSFName.isDeleted()
to check if the name points to cell that no longer exists</action>
            <action dev="POI-DEVELOPERS" type="fix">40414 - fixed selected/active sheet
after removing sheet from workbook</action>
            <action dev="POI-DEVELOPERS" type="fix">44523 - fixed workbook sheet selection
and focus</action>
            <action dev="POI-DEVELOPERS" type="fix">45000 - Fixed NPE in ListLevel when
numberText is null</action>

Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFName.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFName.java?rev=657355&r1=657354&r2=657355&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFName.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFName.java Sat May 17 07:00:30 2008
@@ -139,4 +139,13 @@
 
     }
 
+    /**
+     * Tests if this name points to a cell that no longer exists
+     *
+     * @return true if the name refers to a deleted cell, false otherwise
+     */
+    public boolean isDeleted(){
+        String ref = getReference();
+        return "#REF!".endsWith(ref);
+    }
 }

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestNamedRange.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestNamedRange.java?rev=657355&r1=657354&r2=657355&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestNamedRange.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestNamedRange.java Sat May 17 07:00:30
2008
@@ -533,4 +533,28 @@
 		String contents = c.getStringCellValue();
 		assertEquals("Contents of cell retrieved by its named reference", contents, cvalue);
 	}
+
+    public void testDeletedReference() throws Exception {
+        HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("24207.xls");
+        assertEquals(2, wb.getNumberOfNames());
+
+        HSSFName name1 = wb.getNameAt(0);
+        assertEquals("a", name1.getNameName());
+        assertEquals("Sheet1!$A$1", name1.getReference());
+        AreaReference ref1 = new AreaReference(name1.getReference());
+        assertTrue("Successfully constructed first reference", true);
+
+        HSSFName name2 = wb.getNameAt(1);
+        assertEquals("b", name2.getNameName());
+        assertEquals("#REF!", name2.getReference());
+        assertTrue(name2.isDeleted());
+        try {
+            AreaReference ref2 = new AreaReference(name2.getReference());
+            fail("attempt to supply an invalid reference to AreaReference constructor results
in exception");
+        } catch (Exception e){
+            ;
+        }
+
+    }
+
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message