private WorkbookRecordList _workbookRecordList; // TODO - would be nice to Remove this public LinkTable(List <Record> inputList, int startIndex, WorkbookRecordList workbookRecordList) { _workbookRecordList = workbookRecordList; RecordStream rs = new RecordStream(inputList, startIndex); ArrayList temp = new ArrayList(); while (rs.PeekNextClass() == typeof(SupBookRecord)) { temp.Add(new ExternalBookBlock(rs)); } //_externalBookBlocks = new ExternalBookBlock[temp.Count]; _externalBookBlocks = (ExternalBookBlock[])temp.ToArray(typeof(ExternalBookBlock)); temp.Clear(); if (_externalBookBlocks.Length > 0) { // If any ExternalBookBlock present, there is always 1 of ExternSheetRecord if (rs.PeekNextClass() != typeof(ExternSheetRecord)) { // not quite - if written by google docs _externSheetRecord = null; } else { _externSheetRecord = ReadExtSheetRecord(rs); } } else { _externSheetRecord = null; } _definedNames = new List <NameRecord>(); // collect zero or more DEFINEDNAMEs id=0x18 while (rs.PeekNextClass() == typeof(NameRecord)) { NameRecord nr = (NameRecord)rs.GetNext(); _definedNames.Add(nr); } _recordCount = rs.GetCountRead(); for (int i = startIndex; i < startIndex + _recordCount; i++) { _workbookRecordList.Records.Add(inputList[i]); } }
public void TestStartBlock_EndBlock_Write() { HSSFWorkbook wb = HSSFTestDataSamples.OpenSampleWorkbook("chartdemo.xls"); Record[] sheetRecs = RecordInspector.GetRecords(wb.GetSheetAt(0), 0); RecordStream rs = new RecordStream(Arrays.AsList(sheetRecs), 0); rs.FindChartSubStream(); int pos = rs.GetCountRead(); ChartSheetAggregate csAgg = new ChartSheetAggregate(rs, null); RecordInspector.RecordCollector rv = new RecordInspector.RecordCollector(); csAgg.VisitContainedRecords(rv); Record[] outRecs = rv.Records; for (int i = 0; i < outRecs.Length; i++) { Assert.AreEqual(sheetRecs[pos + i].GetType(), outRecs[i].GetType()); } }
private WorkbookRecordList _workbookRecordList; // TODO - would be nice to Remove this public LinkTable(List<Record> inputList, int startIndex, WorkbookRecordList workbookRecordList, Dictionary<String, NameCommentRecord> commentRecords) { _workbookRecordList = workbookRecordList; RecordStream rs = new RecordStream(inputList, startIndex); ArrayList temp = new ArrayList(); while (rs.PeekNextClass() == typeof(SupBookRecord)) { temp.Add(new ExternalBookBlock(rs)); } //_externalBookBlocks = new ExternalBookBlock[temp.Count]; _externalBookBlocks = (ExternalBookBlock[])temp.ToArray(typeof(ExternalBookBlock)); temp.Clear(); if (_externalBookBlocks.Length > 0) { // If any ExternalBookBlock present, there is always 1 of ExternSheetRecord if (rs.PeekNextClass() != typeof(ExternSheetRecord)) { // not quite - if written by google docs _externSheetRecord = null; } else { _externSheetRecord = ReadExtSheetRecord(rs); } } else { _externSheetRecord = null; } _definedNames = new List<NameRecord>(); // collect zero or more DEFINEDNAMEs id=0x18 while (true) { Type nextClass = rs.PeekNextClass(); if (nextClass == typeof(NameRecord)) { NameRecord nr = (NameRecord)rs.GetNext(); _definedNames.Add(nr); } else if (nextClass == typeof(NameCommentRecord)) { NameCommentRecord ncr = (NameCommentRecord)rs.GetNext(); //commentRecords.Add(ncr.NameText, ncr); commentRecords[ncr.NameText] = ncr; } else { break; } } _recordCount = rs.GetCountRead(); for (int i = startIndex; i < startIndex + _recordCount; i++) { _workbookRecordList.Records.Add(inputList[i]); } }
private WorkbookRecordList _workbookRecordList; // TODO - would be nice to Remove this public LinkTable(IList inputList, int startIndex, WorkbookRecordList workbookRecordList) { _workbookRecordList = workbookRecordList; RecordStream rs = new RecordStream(inputList, startIndex); ArrayList temp = new ArrayList(); while (rs.PeekNextClass() == typeof(SupBookRecord)) { temp.Add(new ExternalBookBlock(rs)); } //_externalBookBlocks = new ExternalBookBlock[temp.Count]; _externalBookBlocks=(ExternalBookBlock[])temp.ToArray(typeof(ExternalBookBlock)); temp.Clear(); if (_externalBookBlocks.Length > 0) { // If any ExternalBookBlock present, there Is always 1 of ExternSheetRecord Record next = rs.GetNext(); _externSheetRecord = (ExternSheetRecord)next; } else { _externSheetRecord = null; } _definedNames = new ArrayList(); // collect zero or more DEFINEDNAMEs id=0x18 while (rs.PeekNextClass() == typeof(NameRecord)) { NameRecord nr = (NameRecord)rs.GetNext(); _definedNames.Add(nr); } _recordCount = rs.GetCountRead(); for(int i=startIndex;i< startIndex + _recordCount;i++) { _workbookRecordList.Records.Add(inputList[i]); } }