Click here to Skip to main content
15,895,667 members
Articles / Web Development / HTML

Transformalizing NorthWind

Rate me:
Please Sign up or sign in to vote.
4.95/5 (29 votes)
24 Jul 2014GPL37 min read 57.8K   341   53  
Combining de-normalization, transformation, replication, and awesome-ness.
#region License
// /*
// See license included in this library folder.
// */
#endregion

using System.Collections.Generic;

namespace Transformalize.Libs.ExcelDataReader.Core.BinaryFormat
{
	/// <summary>
	/// Represents a worksheet index
	/// </summary>
	internal class XlsBiffIndex : XlsBiffRecord
	{
		private bool isV8 = true;

		internal XlsBiffIndex(byte[] bytes, uint offset)
			: base(bytes, offset)
		{
		}

		internal XlsBiffIndex(byte[] bytes)
			: this(bytes, 0)
		{
		}

		/// <summary>
		/// Gets or sets if BIFF8 addressing is used
		/// </summary>
		public bool IsV8
		{
			get { return isV8; }
			set { isV8 = value; }
		}

		/// <summary>
		/// Returns zero-based index of first existing row
		/// </summary>
		public uint FirstExistingRow
		{
			get { return (isV8) ? base.ReadUInt32(0x4) : base.ReadUInt16(0x4); }
		}

		/// <summary>
		/// Returns zero-based index of last existing row
		/// </summary>
		public uint LastExistingRow
		{
			get { return (isV8) ? base.ReadUInt32(0x8) : base.ReadUInt16(0x6); }
		}

		/// <summary>
		/// Returns addresses of DbCell records
		/// </summary>
		public uint[] DbCellAddresses
		{
			get
			{
				int size = RecordSize;
				var firstIdx = (isV8) ? 16 : 12;
				if (size <= firstIdx)
					return new uint[0];
				var cells = new List<uint>((size - firstIdx)/4);
				for (var i = firstIdx; i < size; i += 4)
					cells.Add(base.ReadUInt32(i));
				return cells.ToArray();
			}
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


Written By
Software Developer (Senior)
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions