/// <summary> /// Returns an index into Workbook.ExtendedFormats for the given cell and preceding ixfe record. /// </summary> private int GetXfIndexForCell(XlsBiffBlankCell cell, XlsBiffRecord ixfe) { if (Workbook.BiffVersion == 2) { if (cell.XFormat == 63 && ixfe != null) { var xFormat = ixfe.ReadUInt16(0); return(xFormat); } else if (cell.XFormat > 63) { // Invalid XF ref on cell in BIFF2 stream return(-1); } else if (cell.XFormat < Workbook.ExtendedFormats.Count) { return(cell.XFormat); } else { // Either the file has no XFs, or XF was out of range return(-1); } } return(cell.XFormat); }
/// <summary> /// Reads record at specified offset, does not change cursor position /// </summary> /// <param name="offset"></param> /// <returns></returns> public XlsBiffRecord ReadAt(int offset) { XlsBiffRecord rec = XlsBiffRecord.GetRecord(bytes, (uint)offset); if (m_offset + rec.Size > m_size) { return(null); } return(rec); }
public XlsBiffRecord ReadAt(int offset) { XlsBiffRecord record = XlsBiffRecord.GetRecord(this.bytes, (uint)offset); if ((this.m_offset + record.Size) > this.m_size) { return(null); } return(record); }
private XlsRowBlock ReadNextBlock(XlsBiffStream biffStream, int startRow, int rows, int minOffset, int maxOffset) { var result = new XlsRowBlock { Rows = new Dictionary <int, Row>() }; // Ensure rows with physical records are initialized with height for (var i = 0; i < rows; i++) { if (RowOffsetMap.TryGetValue(startRow + i, out _)) { EnsureRow(result, startRow + i); } } if (minOffset == int.MaxValue) { return(result); } biffStream.Position = minOffset; XlsBiffRecord rec; XlsBiffRecord ixfe = null; while (biffStream.Position <= maxOffset && (rec = biffStream.Read()) != null) { if (rec.Id == BIFFRECORDTYPE.IXFE) { // BIFF2: If cell.xformat == 63, this contains the actual XF index >= 63 ixfe = rec; } if (rec is XlsBiffBlankCell cell) { var currentRow = EnsureRow(result, cell.RowIndex); if (cell.Id == BIFFRECORDTYPE.MULRK) { var cellValues = ReadMultiCell(cell); currentRow.Cells.AddRange(cellValues); } else { var xfIndex = GetXfIndexForCell(cell, ixfe); var cellValue = ReadSingleCell(biffStream, cell, xfIndex); currentRow.Cells.Add(cellValue); } ixfe = null; } } return(result); }
public XlsBiffRecord Read() { XlsBiffRecord rec = XlsBiffRecord.GetRecord(bytes, (uint)m_offset); m_offset += rec.Size; if (m_offset > m_size) { return(null); } return(rec); }
public XlsBiffRecord Read() { XlsBiffRecord record = XlsBiffRecord.GetRecord(this.bytes, (uint)this.m_offset); this.m_offset += record.Size; if (this.m_offset > this.m_size) { return(null); } return(record); }
/// <summary> /// Reads record at specified offset, does not change cursor position /// </summary> /// <param name="offset"></param> /// <returns></returns> public XlsBiffRecord ReadAt(int offset) { XlsBiffRecord rec = XlsBiffRecord.GetRecord(bytes, (uint)offset, reader); //choose ReadOption.Loose to skip this check (e.g. sql reporting services) if (reader.ReadOption == ReadOption.Strict) { if (m_offset + rec.Size > m_size) { return(null); } } return(rec); }
public XlsBiffRecord Read() { if ((uint)m_offset >= bytes.Length) { return(null); } XlsBiffRecord rec = XlsBiffRecord.GetRecord(bytes, (uint)m_offset, reader); m_offset += rec.Size; if (m_offset > m_size) { return(null); } return(rec); }