// Token: 0x0600015B RID: 347 RVA: 0x00007B74 File Offset: 0x00006B74 private void AddCells(Record record) { Bytes data = record.Data; ushort num = data.Get(0, 2).GetBits().ToUInt16(); ushort num2 = data.Get(2, 2).GetBits().ToUInt16(); ushort num3 = num2; ushort num4 = 4; byte[] array = record.RID; bool flag = false; if (array == RID.MULBLANK) { flag = true; array = RID.BLANK; } else if (array == RID.MULRK) { flag = true; array = RID.RK; } if (flag) { num3 = data.Get(data.Length - 2, 2).GetBits().ToUInt16(); } while (num2 <= num3) { Cell cell = this.Cells.Add((ushort)(num + 1), (ushort)(num2 + 1)); data.Get((int)num4, 2).GetBits().ToUInt16(); num4 += 2; if (array == RID.BLANK) { Bytes data2 = new Bytes(); } else if (array == RID.RK) { Bytes data2 = data.Get((int)num4, 4); num4 += 4; cell.SetValue(array, data2); } else { Bytes data2 = data.Get((int)num4, data.Length - (int)num4); if (array == RID.FORMULA) { FormulaRecord formulaRecord = record as FormulaRecord; cell.SetFormula(data2, formulaRecord.StringRecord); } else { cell.SetValue(array, data2); } } num2 += 1; } }
// Token: 0x0600015A RID: 346 RVA: 0x0000790C File Offset: 0x0000690C internal Worksheet(XlsDocument doc, Record boundSheet, List <Record> sheetRecords) : this(doc) { byte[] byteArray = boundSheet.Data.ByteArray; byte b = byteArray[4]; if (b == 0) { this._visibility = WorksheetVisibilities.Default; } else if (b == 1) { this._visibility = WorksheetVisibilities.Hidden; } else { if (b != 2) { throw new ApplicationException(string.Format("Unknown Visibility {0}", b)); } this._visibility = WorksheetVisibilities.StrongHidden; } byte b2 = byteArray[5]; if (b2 == 0) { this._sheettype = WorksheetTypes.Default; } else if (b2 == 2) { this._sheettype = WorksheetTypes.Chart; } else { if (b2 != 6) { throw new ApplicationException(string.Format("Unknown Sheet Type {0}", b2)); } this._sheettype = WorksheetTypes.VBModule; } List <Record> list = new List <Record>(); List <Record> list2 = new List <Record>(); for (int i = 0; i < sheetRecords.Count; i++) { Record record = sheetRecords[i]; if (record.IsCellRecord()) { if (record.RID == RID.FORMULA) { Record record2 = null; if (i + i < sheetRecords.Count) { record2 = sheetRecords[i + 1]; if (record2.RID != RID.STRING) { record2 = null; } } record = new FormulaRecord(record, record2); } list2.Add(record); } else if (record.RID == RID.ROW) { list.Add(record); } } foreach (Record record3 in list) { Bytes data = record3.Data; ushort rowNum = data.Get(0, 2).GetBits().ToUInt16(); this.Rows.AddRow(rowNum); if (!data.Get(6, 2).GetBits().Values[15]) { data.Get(6, 2).GetBits().Get(0, 14).ToUInt16(); } bool flag = data.Get(10, 1).ByteArray[0] == 1; } foreach (Record record4 in list2) { this.AddCells(record4); } this._name = UnicodeBytes.Read(boundSheet.Data.Get(6, boundSheet.Data.Length - 6), 8); }
internal Worksheet(XlsDocument doc, Record boundSheet, List <Record> sheetRecords) : this(doc) { byte[] byteArray = boundSheet.Data.ByteArray; byte visibility = byteArray[4]; if (visibility == 0x00) { _visibility = WorksheetVisibilities.Visible; } else if (visibility == 0x01) { _visibility = WorksheetVisibilities.Hidden; } else if (visibility == 0x02) { _visibility = WorksheetVisibilities.StrongHidden; } else { throw new ApplicationException(string.Format("Unknown Visibility {0}", visibility)); } byte type = byteArray[5]; if (type == 0x00) { _sheettype = WorksheetTypes.Worksheet; } else if (type == 0x02) { _sheettype = WorksheetTypes.Chart; } else if (type == 0x06) { _sheettype = WorksheetTypes.VBModule; } else { throw new ApplicationException(string.Format("Unknown Sheet Type {0}", type)); } List <Record> rowRecords = new List <Record>(); List <Record> cellRecords = new List <Record>(); for (int i = 0; i < sheetRecords.Count; i++) { Record record = sheetRecords[i]; if (record.IsCellRecord()) { if (record.RID == RID.FORMULA) { Record formulaStringRecord = null; if ((i + i) < sheetRecords.Count) { formulaStringRecord = sheetRecords[i + 1]; if (formulaStringRecord.RID != RID.STRING) { formulaStringRecord = null; } } record = new FormulaRecord(record, formulaStringRecord); } cellRecords.Add(record); } else if (record.RID == RID.ROW) { rowRecords.Add(record); } } //Add the Rows first so they exist for adding the Cells foreach (Record rowRecord in rowRecords) { Bytes rowBytes = rowRecord.Data; ushort rowIndex = rowBytes.Get(0, 2).GetBits().ToUInt16(); Row row = Rows.AddRow(rowIndex); bool isDefaultHeight = rowBytes.Get(6, 2).GetBits().Values[15]; ushort height = 0; if (!isDefaultHeight) { height = rowBytes.Get(6, 2).GetBits().Get(0, 14).ToUInt16(); //TODO: Set height on Row when reading (after Row Height implemented) } bool defaultsWritten = (rowBytes.Get(10, 1).ByteArray[0] == 0x01); if (defaultsWritten) { //TODO: Read ROW record defaults } } foreach (Record record in cellRecords) { AddCells(record); } _name = UnicodeBytes.Read(boundSheet.Data.Get(6, boundSheet.Data.Length - 6), 8); }
internal Worksheet(XlsDocument doc, Record boundSheet, List<Record> sheetRecords) : this(doc) { byte[] byteArray = boundSheet.Data.ByteArray; byte visibility = byteArray[4]; if (visibility == 0x00) _visibility = WorksheetVisibilities.Visible; else if (visibility == 0x01) _visibility = WorksheetVisibilities.Hidden; else if (visibility == 0x02) _visibility = WorksheetVisibilities.StrongHidden; else throw new Exception(string.Format("Unknown Visibility {0}", visibility)); byte type = byteArray[5]; if (type == 0x00) _sheettype = WorksheetTypes.Worksheet; else if (type == 0x02) _sheettype = WorksheetTypes.Chart; else if (type == 0x06) _sheettype = WorksheetTypes.VBModule; else throw new Exception(string.Format("Unknown Sheet Type {0}", type)); List<Record> rowRecords = new List<Record>(); List<Record> cellRecords = new List<Record>(); List<Record> noteRecords = new List<Record>(); for (int i = 0; i < sheetRecords.Count; i++) { Record record = sheetRecords[i]; if (record.IsCellRecord()) { if (record.RID == RID.FORMULA) { Record formulaStringRecord = null; if ((i + i) < sheetRecords.Count) { formulaStringRecord = sheetRecords[i + 1]; if (formulaStringRecord.RID != RID.STRING) formulaStringRecord = null; } record = new FormulaRecord(record, formulaStringRecord); } cellRecords.Add(record); } else if (record.RID == RID.ROW) rowRecords.Add(record); else if (record.RID == RID.NOTE) noteRecords.Add(record); } //Add the Rows first so they exist for adding the Cells foreach (Record rowRecord in rowRecords) { Bytes rowBytes = rowRecord.Data; ushort rowIndex = rowBytes.Get(0, 2).GetBits().ToUInt16(); Row row = Rows.AddRow(rowIndex); bool isDefaultHeight = rowBytes.Get(6, 2).GetBits().Values[15]; ushort height = 0; if (!isDefaultHeight) { height = rowBytes.Get(6, 2).GetBits().Get(0, 14).ToUInt16(); //TODO: Set height on Row when reading (after Row Height implemented) } bool defaultsWritten = (rowBytes.Get(10, 1).ByteArray[0] == 0x01); if (defaultsWritten) { //TODO: Read ROW record defaults } } foreach (Record record in cellRecords) AddCells(record); foreach (Record record in noteRecords) AddNote(record); _name = UnicodeBytes.Read(boundSheet.Data.Get(6, boundSheet.Data.Length - 6), 8); }
private void AddCells(Record record) { Bytes bytes = record.Data; ushort rowIndex = bytes.Get(0, 2).GetBits().ToUInt16(); ushort colIndex = bytes.Get(2, 2).GetBits().ToUInt16(); ushort lastColIndex = colIndex; ushort offset = 4; byte[] rid = record.RID; bool isMulti = false; if (rid == RID.MULBLANK) { isMulti = true; rid = RID.BLANK; } else if (rid == RID.MULRK) { isMulti = true; rid = RID.RK; } if (isMulti) { lastColIndex = bytes.Get(bytes.Length - 2, 2).GetBits().ToUInt16(); } while (colIndex <= lastColIndex) { Cell cell = Cells.Add((ushort)(rowIndex + 1), (ushort)(colIndex + 1)); ushort xfIndex = bytes.Get(offset, 2).GetBits().ToUInt16(); offset += 2; Bytes data; if (rid == RID.BLANK) { data = new Bytes(); } else if (rid == RID.RK) { data = bytes.Get(offset, 4); offset += 4; cell.SetValue(rid, data); } else { data = bytes.Get(offset, bytes.Length - offset); if (rid == RID.FORMULA) { FormulaRecord formulaRecord = record as FormulaRecord; cell.SetFormula(data, formulaRecord.StringRecord); } else { cell.SetValue(rid, data); } } colIndex++; } }