From 1704e174fcccf717c17d92b69f39db260f338109 Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Mon, 16 Jun 2008 13:20:42 +0000 Subject: [PATCH] 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 --- .../org/apache/poi/hssf/model/Workbook.java | 3 ++ .../poi/hssf/record/formula/Area3DPtg.java | 11 ++++-- .../apache/poi/hssf/usermodel/HSSFName.java | 1 - .../apache/poi/hssf/data/30978-deleted.xls | Bin 0 -> 13824 bytes .../poi/hssf/usermodel/TestHSSFWorkbook.java | 34 ++++++++++++++++++ 5 files changed, 46 insertions(+), 3 deletions(-) create mode 100755 src/testcases/org/apache/poi/hssf/data/30978-deleted.xls diff --git a/src/java/org/apache/poi/hssf/model/Workbook.java b/src/java/org/apache/poi/hssf/model/Workbook.java index d87fc2c632..5b38935f4c 100644 --- a/src/java/org/apache/poi/hssf/model/Workbook.java +++ b/src/java/org/apache/poi/hssf/model/Workbook.java @@ -603,6 +603,9 @@ public class Workbook implements Model boundsheets.remove(sheetnum); fixTabIdRecord(); } + + // If we decide that we need to fix up + // NameRecords, do it here } /** diff --git a/src/java/org/apache/poi/hssf/record/formula/Area3DPtg.java b/src/java/org/apache/poi/hssf/record/formula/Area3DPtg.java index 60911edc72..e8f72e9937 100644 --- a/src/java/org/apache/poi/hssf/record/formula/Area3DPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/Area3DPtg.java @@ -269,8 +269,15 @@ public class Area3DPtg extends OperandPtg implements AreaI { StringBuffer retval = new StringBuffer(); String sheetName = Ref3DPtg.getSheetName(book, field_1_index_extern_sheet); if(sheetName != null) { - SheetNameFormatter.appendFormat(retval, sheetName); - retval.append( '!' ); + if(sheetName.length() == 0) { + // What excel does if sheet has been deleted + sheetName = "#REF"; + retval.append(sheetName); + } else { + // Normal + SheetNameFormatter.appendFormat(retval, sheetName); + retval.append( '!' ); + } } // Now the normal area bit diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFName.java b/src/java/org/apache/poi/hssf/usermodel/HSSFName.java index e24ca23ea8..240be13f58 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFName.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFName.java @@ -18,7 +18,6 @@ package org.apache.poi.hssf.usermodel; import org.apache.poi.hssf.model.Workbook; -import org.apache.poi.hssf.record.BoundSheetRecord; import org.apache.poi.hssf.record.NameRecord; import org.apache.poi.hssf.util.RangeAddress; diff --git a/src/testcases/org/apache/poi/hssf/data/30978-deleted.xls b/src/testcases/org/apache/poi/hssf/data/30978-deleted.xls new file mode 100755 index 0000000000000000000000000000000000000000..1daca5bff70bd033247acbb2fbc20c856512eb09 GIT binary patch literal 13824 zcmeHOU1%It6#iy*HrZ{`WRvtKtz=zx(b#0SrdF{K(rm?wf~BQJS~RjvlPwKNv$9#C zijdW|Zxt$i@TDNd7k{9(6!b+())(tTX%I@$r>zJ+ilSg4cKyzo9d~xk)+iLU-W$&S z`R=)M&U|xc_MSVF#cN&Va~C(>L_^w+0B%>pXz}3|>l?gw1njR=r0JEttP?WnKg2*d z#0%LHL{IE$YiWVi0B{pFE;uFTz&DgJyoA-jj>)4_vr}`0{CFXkkKN_;g!(XUi4O~$ zcq5hri*xcU@ea;H!Mio@(flLT{8aN1_LQwCo*kZla2xf&kq7Lw>b$*@2m$wF7xfVH`8Kd%aPo7rX{Q{M~pWnMe!`kEOh7)am10$a~8J zhF{p5oqW-+5Jjupn4ZGsA^&)`qD}%KMC&ygj-qOhVE{uwMvM={)RRog^`+LV_Qq3j z_GMD(Oe*Rmu?hV$u%h2gLv3y&>LN~?+sP6 zwQ*&v(aZXCC8njDEyM(u3$FN2Ue}#*nSsmcH^b$q%jw_CxP_RUUNw1q4!S)2(ui+r zf+w5c15NPoAMi7_gGez@k+Q4UqGfl{(Xyx5swIlha!oN2FRjUu#dJ6JfO5!}9Pkfp<>!~3#z)kW)(2G841lpw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