Esempio n. 1
0
        /// <summary>
        /// Reads record under cursor and advances cursor position to next record
        /// </summary>
        /// <returns></returns>
        public XlsBiffRecord Read()
        {
            //add lock(this) as this is equivalent to [MethodImpl(MethodImplOptions.Synchronized)] on the method
            lock (this)
            {
                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);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Reads record at specified offset, does not change cursor position
        /// </summary>
        /// <param name="offset"></param>
        /// <returns></returns>
        public XlsBiffRecord ReadAt(int offset)
        {
            if ((uint)offset >= bytes.Length)
            {
                return(null);
            }

            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);
        }
        /// <summary>
        /// Reads record under cursor and advances cursor position to next record
        /// </summary>
        /// <returns>The record -or- null.</returns>
        public XlsBiffRecord Read()
        {
            // Minimum record size is 4
            if ((uint)Position + 4 >= _bytes.Length)
            {
                return(null);
            }

            var record = XlsBiffRecord.GetRecord(_bytes, (uint)Position, BiffVersion);

            if (record != null)
            {
                Position += record.Size;
            }

            if (Position > Size)
            {
                record = null;
            }

            return(record);
        }