/// <summary> /// Visit each of the atomic BIFF records contained in this {@link RecordAggregate} in the order /// that they should be written to file. Implementors may or may not return the actual /// Records being used to manage POI's internal implementation. Callers should not /// assume either way, and therefore only attempt to modify those Records after cloning /// </summary> /// <param name="rv"></param> public override void VisitContainedRecords(RecordVisitor rv) { int nItems = records.Count; if (nItems < 1) { return; } ColumnInfoRecord cirPrev = null; for (int i = 0; i < nItems; i++) { ColumnInfoRecord cir = (ColumnInfoRecord)records[i]; rv.VisitRecord(cir); if (cirPrev != null && CIRComparator.CompareColInfos(cirPrev, cir) > 0) { // Excel probably wouldn't mind, but there is much logic in this class // that assumes the column info records are kept in order throw new InvalidOperationException("Column info records are out of order"); } cirPrev = cir; } }
/// <summary> /// Initializes a new instance of the <see cref="ColumnInfoRecordsAggregate"/> class. /// </summary> /// <param name="rs">The rs.</param> public ColumnInfoRecordsAggregate(RecordStream rs) : this() { bool isInOrder = true; ColumnInfoRecord cirPrev = null; while (rs.PeekNextClass() == typeof(ColumnInfoRecord)) { ColumnInfoRecord cir = (ColumnInfoRecord)rs.GetNext(); records.Add(cir); if (cirPrev != null && CIRComparator.CompareColInfos(cirPrev, cir) > 0) { isInOrder = false; } cirPrev = cir; } if (records.Count < 1) { throw new InvalidOperationException("No column info records found"); } if (!isInOrder) { records.Sort(CIRComparator.instance); } }