aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases/org/apache/poi/hssf/usermodel
diff options
context:
space:
mode:
authorNick Burch <nick@apache.org>2008-06-16 13:20:42 +0000
committerNick Burch <nick@apache.org>2008-06-16 13:20:42 +0000
commit1704e174fcccf717c17d92b69f39db260f338109 (patch)
tree3d93244640f3d09f4dc0c6141e278da92a255f6b /src/testcases/org/apache/poi/hssf/usermodel
parentbd44450ddfffff64a06366ceba7808aa68fc6b14 (diff)
downloadpoi-1704e174fcccf717c17d92b69f39db260f338109.tar.gz
poi-1704e174fcccf717c17d92b69f39db260f338109.zip
Slight tweak for named ranges pointing at deleted sheets, related to bug #30978
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@668153 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache/poi/hssf/usermodel')
-rw-r--r--src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java
index b9873fa4b6..2fca481481 100644
--- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java
+++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java
@@ -30,6 +30,7 @@ import org.apache.poi.hssf.model.Sheet;
import org.apache.poi.hssf.record.NameRecord;
import org.apache.poi.hssf.record.Record;
import org.apache.poi.hssf.record.RecordInputStream;
+import org.apache.poi.hssf.record.formula.Area3DPtg;
import org.apache.poi.util.TempFile;
/**
*
@@ -402,6 +403,39 @@ public final class TestHSSFWorkbook extends TestCase {
assertTrue(e.getMessage().startsWith("Actual serialized sheet size"));
}
}
+
+ /**
+ * Checks that us and HSSFName play nicely with named ranges
+ * that point to deleted sheets
+ */
+ public void testNamesToDeleteSheets() throws Exception {
+ HSSFWorkbook b = openSample("30978-deleted.xls");
+ assertEquals(1, b.getNumberOfNames());
+
+ // Sheet 2 deleted
+ assertEquals("Sheet1", b.getSheetName(0));
+ assertEquals("Sheet3", b.getSheetName(1));
+
+ // First at low level
+ NameRecord nr = b.getWorkbook().getNameRecord(0);
+ assertEquals("On2", nr.getNameText());
+ assertEquals(1, nr.getExternSheetNumber());
+ assertEquals(1, nr.getNameDefinition().size());
+
+ Area3DPtg ptg = (Area3DPtg)nr.getNameDefinition().get(0);
+ assertEquals(1, ptg.getExternSheetIndex());
+ assertEquals(0, ptg.getFirstColumn());
+ assertEquals(0, ptg.getFirstRow());
+ assertEquals(0, ptg.getLastColumn());
+ assertEquals(2, ptg.getLastRow());
+
+ // Now at high level
+ HSSFName n = b.getNameAt(0);
+ assertEquals("On2", n.getNameName());
+ assertEquals("", n.getSheetName());
+ assertEquals("#REF$A$1:$A$3", n.getReference());
+ }
+
/**
* result returned by getRecordSize() differs from result returned by serialize()
*/