dimensionrecord.cs

来自「Excel的操作,其中可以读取及写入Excel 文件」· CS 代码 · 共 108 行

CS
108
字号
using System;

using Microsoft.Fawvw.Components.NExcel.Biff;

namespace Microsoft.Fawvw.Components.NExcel.Read.Biff
{
	
	/// <summary> Contains the cell dimensions of this worksheet</summary>
	class DimensionRecord:RecordData
	{
		/// <summary> Accessor for the number of rows in this sheet
		/// 
		/// </summary>
		/// <returns> the number of rows
		/// </returns>
		virtual public int NumberOfRows
		{
			get
			{
				return numRows;
			}
			
		}
		/// <summary> Accessor for the number of columns in this sheet
		/// 
		/// </summary>
		/// <returns> the number of columns
		/// </returns>
		virtual public int NumberOfColumns
		{
			get
			{
				return numCols;
			}
			
		}
		/// <summary> The number of rows in this sheet</summary>
		private int numRows;
		/// <summary> The number of columns in this worksheet</summary>
		private int numCols;
		
		/// <summary> Dummy indicators for overloading the constructor</summary>
		public class Biff7
		{
		}
		
		public static Biff7 biff7;
		
		/// <summary> Constructs the dimensions from the raw data
		/// 
		/// </summary>
		/// <param name="t">the raw data
		/// </param>
		public DimensionRecord(Record t):base(t)
		{
			sbyte[] data = t.Data;
			
			// Sometimes, if the spreadsheet is being generated by dodgy VB modules,
			// even though the excel format is biff8, the dimension record is
			// generated in the old biff 7 format.  This horrible if construct
			// handles that eventuality
			if (data.Length == 10)
			{
				read10ByteData(data);
			}
			else
			{
				read14ByteData(data);
			}
		}
		
		/// <summary> Constructs the dimensions from the raw data
		/// 
		/// </summary>
		/// <param name="t">the raw data
		/// </param>
		/// <param name="biff7">an indicator to initialise this record for biff 7 format
		/// </param>
		public DimensionRecord(Record t, Biff7 biff7):base(t)
		{
			sbyte[] data = t.Data;
			read10ByteData(data);
		}
		
		/// <summary> Reads in the data for data records of .Length 10</summary>
		/// <param name="data">the data to read
		/// </param>
		private void  read10ByteData(sbyte[] data)
		{
			numRows = IntegerHelper.getInt(data[2], data[3]);
			numCols = IntegerHelper.getInt(data[6], data[7]);
		}
		
		/// <summary> Reads in the data for data records of .Length 14</summary>
		/// <param name="data">the data to read
		/// </param>
		private void  read14ByteData(sbyte[] data)
		{
			numRows = IntegerHelper.getInt(data[4], data[5], data[6], data[7]);
			numCols = IntegerHelper.getInt(data[10], data[11]);
		}
		static DimensionRecord()
		{
			biff7 = new Biff7();
		}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?