From 1f08e18ea8d04bb26b2c2fc52de6fb30e356cf86 Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Wed, 18 Jun 2008 11:35:04 +0000 Subject: [PATCH] A partial fix for bug #30978, but something still remains, which seems to be related to changing the ptg git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@669140 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/poi/hssf/model/Workbook.java | 24 ++++++- .../org/apache/poi/hssf/data/30978-alt.xls | Bin 0 -> 14848 bytes .../apache/poi/hssf/usermodel/TestBugs.java | 62 ++++++++++++++++++ 3 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 src/testcases/org/apache/poi/hssf/data/30978-alt.xls diff --git a/src/java/org/apache/poi/hssf/model/Workbook.java b/src/java/org/apache/poi/hssf/model/Workbook.java index 5b38935f4c..fa22cfb688 100644 --- a/src/java/org/apache/poi/hssf/model/Workbook.java +++ b/src/java/org/apache/poi/hssf/model/Workbook.java @@ -604,8 +604,28 @@ public class Workbook implements Model fixTabIdRecord(); } - // If we decide that we need to fix up - // NameRecords, do it here + // Within NameRecords, it's ok to have the formula + // part point at deleted sheets. It's also ok to + // have the ExternSheetNumber point at deleted + // sheets. + // However, the sheet index must be adjusted, or + // excel will break. (Sheet index is either 0 for + // global, or 1 based index to sheet) + int sheetNum1Based = sheetnum + 1; + for(int i=0; i sheetNum1Based) { + // Bump down by one, so still points + // at the same sheet + nr.setEqualsToIndexToSheet((short)( + nr.getEqualsToIndexToSheet()-1 + )); + } + } } /** diff --git a/src/testcases/org/apache/poi/hssf/data/30978-alt.xls b/src/testcases/org/apache/poi/hssf/data/30978-alt.xls new file mode 100644 index 0000000000000000000000000000000000000000..c591582885aef5e605d28e22c31761b8d74540c5 GIT binary patch literal 14848 zcmeHOU2IfE6#njVx7`AT{_$5}bKRo-rN0TFw6s_tXeba`LzN}9v|Fi^uGuaLO*AeF z48ExbOzXz#7cJ-O(&$B+w0}7d!7cVE*W+ygIm$X_7SjhcuAo zVMk`Tv9I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