import org.apache.poi.hssf.model.Workbook;
import org.apache.poi.hssf.record.formula.Area3DPtg;
+import org.apache.poi.hssf.record.formula.DeletedArea3DPtg;
+import org.apache.poi.hssf.record.formula.DeletedRef3DPtg;
import org.apache.poi.hssf.record.formula.Ptg;
import org.apache.poi.hssf.record.formula.Ref3DPtg;
import org.apache.poi.hssf.util.RangeAddress;
* @return area reference
*/
public String getAreaReference(Workbook book){
- if (field_13_name_definition == null || field_13_name_definition.isEmpty()) return "#REF!";
+ if (field_13_name_definition == null || field_13_name_definition.isEmpty()) return "Error";
Ptg ptg = (Ptg) field_13_name_definition.peek();
String result = "";
} else if (ptg.getClass() == Ref3DPtg.class){
result = ptg.toFormulaString(book);
- }
+ } else if (ptg.getClass() == DeletedArea3DPtg.class || ptg.getClass() == DeletedRef3DPtg.class) {
+ result = "#REF!" ; }
return result;
}
--- /dev/null
+/* ====================================================================
+ Copyright 2003-2005 Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hssf.record.formula;
+
+/**
+ * Title: Deleted Area 3D Ptg - 3D referecnce (Sheet + Area)<P>
+ * Description: Defined a area in Extern Sheet. <P>
+ * REFERENCE: <P>
+ * @author Patrick Luby
+ * @version 1.0-pre
+ */
+
+public class DeletedArea3DPtg extends Area3DPtg
+{
+ public final static byte sid = 0x3d;
+
+ /** Creates new DeletedArea3DPtg */
+ public DeletedArea3DPtg( String arearef, short externIdx )
+ {
+ super(arearef, externIdx);
+ }
+
+ public DeletedArea3DPtg( byte[] data, int offset )
+ {
+ super(data, offset);
+ }
+}
--- /dev/null
+/* ====================================================================
+ Copyright 2003-2005 Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+
+package org.apache.poi.hssf.record.formula;
+
+/**
+ * Title: Deleted Reference 3D Ptg <P>
+ * Description: Defined a cell in extern sheet. <P>
+ * REFERENCE: <P>
+ * @author Patrick Luby
+ * @version 1.0-pre
+ */
+
+public class DeletedRef3DPtg extends Ref3DPtg {
+ public final static byte sid = 0x3c;
+
+ /** Creates new DeletedRef3DPtg */
+ public DeletedRef3DPtg(byte[] data, int offset) {
+ super(data, offset);
+ }
+
+ public DeletedRef3DPtg(String cellref, short externIdx ) {
+ super(cellref, externIdx);
+ }
+}
retval = new Ref3DPtg(data, offset);
break;
+ case DeletedArea3DPtg.sid : // 0x3c
+ case DeletedArea3DPtg.sid+0x20 : // 0x5c
+ case DeletedArea3DPtg.sid+0x40 : // 0x7c
+
+ retval = new DeletedArea3DPtg(data, offset);
+ break;
+
+ case DeletedRef3DPtg.sid: // 0x3d
+ case DeletedRef3DPtg.sid+0x20: // 0x5d
+ case DeletedRef3DPtg.sid+0x40: // 0x7d
+
+ retval = new DeletedRef3DPtg(data, offset);
+ break;
+
case MissingArgPtg.sid:
retval = new MissingArgPtg(data,offset);
break;
File file = TempFile.createTempFile("testComplexSheetRefs",".xls");
sb.write(new FileOutputStream(file));
}
+
+ /*Unknown Ptg 3C*/
+ public void test27272_1() throws Exception {
+ String readFilename = System.getProperty("HSSF.testdata.path");
+ File inFile = new File(readFilename+"/27272_1.xls");
+ FileInputStream in = new FileInputStream(inFile);
+ HSSFWorkbook wb = new HSSFWorkbook(in);
+ wb.getSheetAt(0);
+ assertEquals("Reference for named range ", "#REF!",wb.getNameAt(0).getReference());
+ File outF = File.createTempFile("bug27272_1",".xls");
+ wb.write(new FileOutputStream(outF));
+ System.out.println("Open "+outF.getAbsolutePath()+" in Excel");
+ }
+ /*Unknown Ptg 3D*/
+ public void test27272_2() throws Exception {
+ String readFilename = System.getProperty("HSSF.testdata.path");
+ File inFile = new File(readFilename+"/27272_2.xls");
+ FileInputStream in = new FileInputStream(inFile);
+ HSSFWorkbook wb = new HSSFWorkbook(in);
+ assertEquals("Reference for named range ", "#REF!",wb.getNameAt(0).getReference());
+ File outF = File.createTempFile("bug27272_2",".xls");
+ wb.write(new FileOutputStream(outF));
+ System.out.println("Open "+outF.getAbsolutePath()+" in Excel");
+ }
+
+
public static void main(String [] args) {
System.out
.println("Testing org.apache.poi.hssf.usermodel.TestFormulas");