Index: src/java/org/apache/poi/hssf/model/WorkbookRecordList.java =================================================================== --- src/java/org/apache/poi/hssf/model/WorkbookRecordList.java (revision 1100785) +++ src/java/org/apache/poi/hssf/model/WorkbookRecordList.java (working copy) @@ -22,9 +22,11 @@ import java.util.List; import org.apache.poi.hssf.record.Record; +import org.apache.poi.hssf.record.StyleRecord; public final class WorkbookRecordList implements Iterable { private List records = new ArrayList(); + private List styleRecords = new ArrayList(); private int protpos = 0; // holds the position of the protect record. private int bspos = 0; // holds the position of the last bound sheet. @@ -40,8 +42,18 @@ public void setRecords(List records) { this.records = records; + styleRecords.clear(); + for(Record r: records) { + if(r instanceof StyleRecord) { + styleRecords.add((StyleRecord)r); + } + } } + public List getStyleRecords() { + return styleRecords; + } + public int size() { return records.size(); } @@ -52,6 +64,9 @@ public void add(int pos, Record r) { records.add(pos, r); + if(r instanceof StyleRecord) { + styleRecords.add((StyleRecord)r); + } if (getProtpos() >= pos) setProtpos( protpos + 1 ); if (getBspos() >= pos) setBspos( bspos + 1 ); if (getTabpos() >= pos) setTabpos( tabpos + 1 ); @@ -79,7 +94,8 @@ public void remove( int pos ) { - records.remove(pos); + Record r = records.remove(pos); + styleRecords.remove(r); if (getProtpos() >= pos) setProtpos( protpos - 1 ); if (getBspos() >= pos) setBspos( bspos - 1 ); if (getTabpos() >= pos) setTabpos( tabpos - 1 ); Index: src/java/org/apache/poi/hssf/model/InternalWorkbook.java =================================================================== --- src/java/org/apache/poi/hssf/model/InternalWorkbook.java (revision 1100785) +++ src/java/org/apache/poi/hssf/model/InternalWorkbook.java (working copy) @@ -867,15 +867,7 @@ public StyleRecord getStyleRecord(int xfIndex) { // Style records always follow after // the ExtendedFormat records - for(int i=records.getXfpos(); i