From 1a13734e19d08816e13366bc761e73c5777c4b14 Mon Sep 17 00:00:00 2001 From: "Andrew C. Oliver" Date: Mon, 4 Jun 2007 13:52:57 +0000 Subject: [PATCH] http://issues.apache.org/bugzilla/show_bug.cgi?id=23951 git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@544151 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/poi/hssf/model/Workbook.java | 14 +++++++++++++- .../apache/poi/hssf/usermodel/HSSFWorkbook.java | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/java/org/apache/poi/hssf/model/Workbook.java b/src/java/org/apache/poi/hssf/model/Workbook.java index be5c870a8..5071735b6 100644 --- a/src/java/org/apache/poi/hssf/model/Workbook.java +++ b/src/java/org/apache/poi/hssf/model/Workbook.java @@ -738,6 +738,7 @@ public class Workbook implements Model SSTRecord sst = null; int sstPos = 0; + boolean wroteBoundSheets = false; for ( int k = 0; k < records.size(); k++ ) { @@ -745,6 +746,7 @@ public class Workbook implements Model // Let's skip RECALCID records, as they are only use for optimization if ( record.getSid() != RecalcIdRecord.sid || ( (RecalcIdRecord) record ).isNeeded() ) { + int len = 0; if (record instanceof SSTRecord) { sst = (SSTRecord)record; @@ -754,7 +756,17 @@ public class Workbook implements Model { record = sst.createExtSSTRecord(sstPos + offset); } - int len = record.serialize( pos + offset, data ); + if (record instanceof BoundSheetRecord) { + if(!wroteBoundSheets) { + for (int i = 0; i < boundsheets.size(); i++) { + len+= ((BoundSheetRecord)boundsheets.get(i)) + .serialize(pos+offset+len, data); + } + wroteBoundSheets = true; + } + } else { + len = record.serialize( pos + offset, data ); + } ///// DEBUG BEGIN ///// // if (len != record.getRecordSize()) // throw new IllegalStateException("Record size does not match serialized bytes. Serialized size = " + len + " but getRecordSize() returns " + record.getRecordSize()); diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java b/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java index f90717e98..4b0a0bbcf 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java @@ -321,6 +321,7 @@ public class HSSFWorkbook */ public void setSheetOrder(String sheetname, int pos ) { + sheets.add(pos,sheets.remove(getSheetIndex(sheetname))); workbook.setSheetOrder(sheetname, pos); }