// Token: 0x06000152 RID: 338 RVA: 0x000076FC File Offset: 0x000066FC private void DecodeFORMULA(Bytes data, Record stringRecord) { if (stringRecord != null) { this._value = UnicodeBytes.Read(stringRecord.Data, 16); } this._type = CellTypes.Formula; }
private void DecodeFORMULA(Bytes data, Record stringRecord) { //TODO: Read in formula properties if (stringRecord != null) { _value = UnicodeBytes.Read(stringRecord.Data, 16); } _type = CellTypes.Formula; }
// Token: 0x060002A4 RID: 676 RVA: 0x0000C89C File Offset: 0x0000B89C internal static string Read(Record record, int lengthBits, ref int continueIndex, ref ushort offset) { string empty = string.Empty; UnicodeBytes.ReadState readState = new UnicodeBytes.ReadState(record, lengthBits, continueIndex, offset); UnicodeBytes.Read(readState); continueIndex = readState.ContinueIndex; offset = readState.Offset; return(new string(readState.CharactersRead.ToArray())); }
private void AddNote(Record record) { Bytes bytes = record.Data; ushort rowIndex = bytes.Get(0, 2).GetBits().ToUInt16(); ushort colIndex = bytes.Get(2, 2).GetBits().ToUInt16(); Bytes options = bytes.Get(4, 2); ushort objId = bytes.Get(6, 2).GetBits().ToUInt16(); string authorName = UnicodeBytes.Read(bytes.Get(8, bytes.Length - 8), 16); Debugger.Break(); }
// Token: 0x06000217 RID: 535 RVA: 0x0000A398 File Offset: 0x00009398 private void ReadBytes(Bytes bytes) { byte[] byteArray = bytes.ByteArray; this._height = BitConverter.ToUInt16(byteArray, 0); this.SetOptionsValue(bytes.Get(2, 2)); this._colorIndex = BitConverter.ToUInt16(byteArray, 4); this._weight = FontWeightConverter.Convert(BitConverter.ToUInt16(byteArray, 6)); this._escapement = (EscapementTypes)BitConverter.ToUInt16(byteArray, 8); this._underline = (UnderlineTypes)byteArray[10]; this._fontFamily = (FontFamilies)byteArray[11]; this._characterSet = (CharacterSets)byteArray[12]; this._fontName = UnicodeBytes.Read(bytes.Get(14, bytes.Length - 14), 8); }
private void ReadBytes(Bytes bytes) { byte[] byteArray = bytes.ByteArray; _height = BitConverter.ToUInt16(byteArray, 0); SetOptionsValue(bytes.Get(2, 2)); _color = _doc.Workbook.Palette.GetColor(BitConverter.ToUInt16(byteArray, 4)); _weight = FontWeightConverter.Convert(BitConverter.ToUInt16(byteArray, 6)); _escapement = (EscapementTypes)BitConverter.ToUInt16(byteArray, 8); _underline = (UnderlineTypes)byteArray[10]; _fontFamily = (FontFamilies)byteArray[11]; _characterSet = (CharacterSets)byteArray[12]; //skip byte index 13 _fontName = UnicodeBytes.Read(bytes.Get(14, bytes.Length - 14), 8); }
//TODO: Implement Rich Text Value support //TODO: Implement Asian Text Value support internal void ReadBytes(Record sstRecord) { uint totalStrings = sstRecord.Data.Get(0, 4).GetBits().ToUInt32(); uint uniqueStrings = sstRecord.Data.Get(4, 4).GetBits().ToUInt32(); int stringIndex = 0; ushort offset = 8; int continueIndex = -1; while (stringIndex < uniqueStrings) { string sharedString = UnicodeBytes.Read(sstRecord, 16, ref continueIndex, ref offset); Add(sharedString); stringIndex++; } _countAll = totalStrings; }
// Token: 0x060000B5 RID: 181 RVA: 0x00005A2C File Offset: 0x00004A2C internal void ReadBytes(Record sstRecord) { uint countAll = sstRecord.Data.Get(0, 4).GetBits().ToUInt32(); uint num = sstRecord.Data.Get(4, 4).GetBits().ToUInt32(); int num2 = 0; ushort num3 = 8; int num4 = -1; while ((long)num2 < (long)((ulong)num)) { string sharedString = UnicodeBytes.Read(sstRecord, 16, ref num4, ref num3); this.Add(sharedString); num2++; } this._countAll = countAll; }
// Token: 0x06000155 RID: 341 RVA: 0x0000775B File Offset: 0x0000675B private void DecodeLABEL(Bytes data) { this._value = UnicodeBytes.Read(data, 16); this._type = CellTypes.Text; }
// 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); }
// Token: 0x060002A5 RID: 677 RVA: 0x0000C8E4 File Offset: 0x0000B8E4 private static void Read(UnicodeBytes.ReadState state) { Bytes recordData = state.GetRecordData(); bool flag = (state.OptionsFlags & 1) == 0; ushort num = (ushort)(recordData.Length - (int)state.Offset); if (state.CharactersRead.Count < (int)state.TotalCharacters) { ushort num2 = (ushort)((int)state.TotalCharacters - state.CharactersRead.Count); if (!flag) { num2 *= 2; } ushort num3; if (num < num2) { num3 = num; } else { num3 = num2; } byte[] array = recordData.Get((int)state.Offset, (int)num3).ByteArray; if (flag) { byte[] array2 = new byte[array.Length * 2]; for (int i = 0; i < array.Length; i++) { array2[2 * i] = array[i]; } array = array2; } state.Offset += num3; num -= num3; state.CharactersRead.AddRange(Encoding.Unicode.GetChars(array)); } bool flag2 = state.CharactersRead.Count == (int)state.TotalCharacters; if (state.HasRichTextSettings && num > 0 && flag2 && state.FormattingRunBytes.Count < (int)(state.FormattingRunCount * 4)) { ushort num3 = Math.Min(num, (ushort)Math.Min((int)(state.FormattingRunCount * 4), 65535)); state.FormattingRunBytes.AddRange(recordData.Get((int)state.Offset, (int)num3).ByteArray); state.Offset += num3; num -= num3; } if (state.HasAsianPhonetics && num > 0 && flag2 && (long)state.PhoneticSettingsBytes.Count < (long)((ulong)state.PhoneticSettingsByteCount)) { ushort num3 = Math.Min(num, (ushort)Math.Min(state.PhoneticSettingsByteCount, 65535U)); state.PhoneticSettingsBytes.AddRange(recordData.Get((int)state.Offset, (int)num3).ByteArray); state.Offset += num3; num -= num3; } if (state.CharactersRead.Count < (int)state.TotalCharacters || state.FormattingRunBytes.Count < (int)(state.FormattingRunCount * 4) || (long)state.PhoneticSettingsBytes.Count < (long)((ulong)state.PhoneticSettingsByteCount)) { state.Continue(true); UnicodeBytes.Read(state); return; } if (num == 0 && state.ContinueIndex + 1 < state.Record.Continues.Count) { state.Continue(false); } }
// Token: 0x060002A3 RID: 675 RVA: 0x0000C880 File Offset: 0x0000B880 private static string Read(Record record, int lengthBits, ushort offset) { int num = -1; return(UnicodeBytes.Read(record, lengthBits, ref num, ref offset)); }
// Token: 0x060002A2 RID: 674 RVA: 0x0000C85C File Offset: 0x0000B85C internal static string Read(Bytes bytes, int lengthBits) { Record record = new Record(RID.Empty, bytes); return(UnicodeBytes.Read(record, lengthBits, 0)); }
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); }
private void ReadBytes(Bytes bytes, BytesReadCallback bytesReadCallback) { if (bytes == null) { throw new ArgumentNullException("bytes"); } if (bytes.Length == 0) { throw new ArgumentException("can't be zero-length", "bytes"); } //The XF's read in won't necessarily have the same ID (index) once added to this Workbook, //so we need to keep the cross-reference list for re-assignment as we read in the cell records later SortedList <ushort, ushort> xfIdLookups = new SortedList <ushort, ushort>(); List <Record> records = Record.GetAll(bytes); List <Record> fontRecords = new List <Record>(); List <Record> formatRecords = new List <Record>(); List <Record> xfRecords = new List <Record>(); List <Record> boundSheetRecords = new List <Record>(); Record sstRecord = Record.Empty; SortedList <int, List <Record> > sheetRecords = new SortedList <int, List <Record> >(); int sheetIndex = -1; foreach (Record record in records) { if (sheetIndex >= 0) { if (!sheetRecords.ContainsKey(sheetIndex)) { sheetRecords[sheetIndex] = new List <Record>(); } sheetRecords[sheetIndex].Add(record); if (record.RID == RID.EOF) { sheetIndex++; } } else if (record.RID == RID.FONT) { fontRecords.Add(record); } else if (record.RID == RID.FORMAT) { formatRecords.Add(record); } else if (record.RID == RID.XF) { xfRecords.Add(record); } else if (record.RID == RID.BOUNDSHEET) { boundSheetRecords.Add(record); } else if (record.RID == RID.SST) { sstRecord = record; } else if (record.RID == RID.EOF) { sheetIndex++; } } SortedList <ushort, Font> fonts = new SortedList <ushort, Font>(); SortedList <ushort, string> formats = new SortedList <ushort, string>(); SortedList <ushort, XF> xfs = new SortedList <ushort, XF>(); ushort index = 0; foreach (Record record in fontRecords) { Font font = new Font(_doc, record.Data); fonts[index++] = font; this.Fonts.Add(font); } foreach (Record record in formatRecords) { Bytes recordData = record.Data; string format = UnicodeBytes.Read(recordData.Get(2, recordData.Length - 2), 16); index = BitConverter.ToUInt16(recordData.Get(2).ByteArray, 0); formats[index] = format; this.Formats.Add(format); } index = 0; for (index = 0; index < xfRecords.Count; index++) { Record record = xfRecords[index]; Bytes recordData = record.Data; ushort fontIndex = BitConverter.ToUInt16(recordData.Get(0, 2).ByteArray, 0); ushort formatIndex = BitConverter.ToUInt16(recordData.Get(2, 2).ByteArray, 0); //ushort styleIndex = BitConverter.ToUInt16(recordData.Get(4, 2)) if (!fonts.ContainsKey(fontIndex)) { continue; //TODO: Perhaps default to default XF? NOTE: This is encountered with TestReferenceFile BlankBudgetWorksheet.xls } Font font = fonts[fontIndex]; string format; if (formats.ContainsKey(formatIndex)) { format = formats[formatIndex]; } else if (_formats.ContainsKey(formatIndex)) { format = _formats[formatIndex]; } else { throw new ApplicationException(string.Format("Format {0} not found in read FORMAT records or standard/default FORMAT records.", formatIndex)); } xfIdLookups[index] = this.XFs.Add(new XF(_doc, record.Data, font, format)); } this.XFs.XfIdxLookups = xfIdLookups; if (sstRecord != Record.Empty) { this.SharedStringTable.ReadBytes(sstRecord); } if (bytesReadCallback != null) { bytesReadCallback(records); } for (int i = 0; i < boundSheetRecords.Count; i++) { _worksheets.Add(boundSheetRecords[i], sheetRecords[i]); } }
// Token: 0x060000CA RID: 202 RVA: 0x00005FE0 File Offset: 0x00004FE0 private void ReadBytes(Bytes bytes, Workbook.BytesReadCallback bytesReadCallback) { if (bytes == null) { throw new ArgumentNullException("bytes"); } if (bytes.Length == 0) { throw new ArgumentException("can't be zero-length", "bytes"); } SortedList <ushort, ushort> sortedList = new SortedList <ushort, ushort>(); List <Record> all = Record.GetAll(bytes); List <Record> list = new List <Record>(); List <Record> list2 = new List <Record>(); List <Record> list3 = new List <Record>(); List <Record> list4 = new List <Record>(); Record record = Record.Empty; SortedList <int, List <Record> > sortedList2 = new SortedList <int, List <Record> >(); int num = -1; foreach (Record record2 in all) { if (num >= 0) { if (!sortedList2.ContainsKey(num)) { sortedList2[num] = new List <Record>(); } sortedList2[num].Add(record2); if (record2.RID == RID.EOF) { num++; } } else if (record2.RID == RID.FONT) { list.Add(record2); } else if (record2.RID == RID.FORMAT) { list2.Add(record2); } else if (record2.RID == RID.XF) { list3.Add(record2); } else if (record2.RID == RID.BOUNDSHEET) { list4.Add(record2); } else if (record2.RID == RID.SST) { record = record2; } else if (record2.RID == RID.EOF) { num++; } } SortedList <ushort, Font> sortedList3 = new SortedList <ushort, Font>(); SortedList <ushort, string> sortedList4 = new SortedList <ushort, string>(); new SortedList <ushort, XF>(); ushort num2 = 0; foreach (Record record3 in list) { Font font = new Font(this._doc, record3.Data); SortedList <ushort, Font> sortedList5 = sortedList3; ushort num3 = num2; num2 = (ushort)(num3 + 1); sortedList5[num3] = font; this.Fonts.Add(font); } foreach (Record record4 in list2) { Bytes data = record4.Data; string text = UnicodeBytes.Read(data.Get(2, data.Length - 2), 16); num2 = BitConverter.ToUInt16(data.Get(2).ByteArray, 0); sortedList4[num2] = text; this.Formats.Add(text); } num2 = 0; while ((int)num2 < list3.Count) { Record record5 = list3[(int)num2]; Bytes data2 = record5.Data; ushort key = BitConverter.ToUInt16(data2.Get(0, 2).ByteArray, 0); ushort num4 = BitConverter.ToUInt16(data2.Get(2, 2).ByteArray, 0); if (sortedList3.ContainsKey(key)) { Font font2 = sortedList3[key]; string format; if (sortedList4.ContainsKey(num4)) { format = sortedList4[num4]; } else { if (!this._formats.ContainsKey(num4)) { throw new ApplicationException(string.Format("Format {0} not found in read FORMAT records or standard/default FORMAT records.", num4)); } format = this._formats[num4]; } sortedList[num2] = this.XFs.Add(new XF(this._doc, record5.Data, font2, format)); } num2 += 1; } this.XFs.XfIdxLookups = sortedList; if (record != Record.Empty) { this.SharedStringTable.ReadBytes(record); } if (bytesReadCallback != null) { bytesReadCallback(all); } for (int i = 0; i < list4.Count; i++) { this._worksheets.Add(list4[i], sortedList2[i]); } }