⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 boundsheetrecord.cs

📁 Excel的操作,其中可以读取及写入Excel 文件
💻 CS
字号:
using System;
using System.Text;

using Microsoft.Fawvw.Components.NExcel.Biff;

namespace Microsoft.Fawvw.Components.NExcel.Read.Biff
{
	
	/// <summary> A boundsheet record, which contains the worksheet name</summary>
	class BoundsheetRecord:RecordData
	{
		/// <summary> Accessor for the worksheet name
		/// 
		/// </summary>
		/// <returns> the worksheet name
		/// </returns>
		virtual public string Name
		{
			get
			{
				return name;
			}
			
		}
		/// <summary> Accessor for the hidden flag
		/// 
		/// </summary>
		/// <returns> TRUE if this is a hidden sheet, FALSE otherwise
		/// </returns>
		virtual public bool isHidden()
		{
				return visibilityFlag != 0;
		}

		/// <summary> Accessor to determine if this is a worksheet, or some other nefarious
		/// type of object
		/// 
		/// </summary>
		/// <returns> TRUE if this is a worksheet, FALSE otherwise
		/// </returns>
		virtual public bool isSheet()
		{
				return typeFlag == 0;
		}

		/// <summary> Accessor to determine if this is a chart
		/// 
		/// </summary>
		/// <returns> TRUE if this is a chart, FALSE otherwise
		/// </returns>
		virtual public bool Chart
		{
			get
			{
				return typeFlag == 2;
			}
			
		}
		/// <summary> The offset into the sheet</summary>
		private int offset;
		/// <summary> The type of sheet this is</summary>
		private sbyte typeFlag;
		/// <summary> The visibility flag</summary>
		private sbyte visibilityFlag;
		/// <summary> The length of the worksheet name</summary>
		private int length;
		/// <summary> The worksheet name</summary>
		private string name;
		
		/// <summary> Dummy indicators for overloading the constructor</summary>
		public class Biff7
		{
		}
		
		public static Biff7 biff7;
		
		/// <summary> Constructs this object from the raw data
		/// 
		/// </summary>
		/// <param name="t">the raw data
		/// </param>
		public BoundsheetRecord(Record t):base(t)
		{
			sbyte[] data = getRecord().Data;
			offset = IntegerHelper.getInt(data[0], data[1], data[2], data[3]);
			typeFlag = data[5];
			visibilityFlag = data[4];
			length = data[6];
			
			if (data[7] == 0)
			{
				// Standard ASCII encoding
				sbyte[] bytes = new sbyte[length];
				Array.Copy(data, 8, bytes, 0, length);
				name = new string(ExcelUtils.Byte.ToCharArray(ExcelUtils.Byte.ToByteArray(bytes)));
			}
			else
			{
				// little endian Unicode encoding
				sbyte[] bytes = new sbyte[length * 2];
				Array.Copy(data, 8, bytes, 0, length * 2);
				try
				{
					// [TODO] - test if it is right - critical
					// name = new String(bytes, "UnicodeLittle");
//					name = new string(NExcelUtils.Byte.ToCharArray(NExcelUtils.Byte.ToByteArray(bytes)));
					byte[] bb = ExcelUtils.Byte.ToByteArray(bytes);
					Encoding encoding = Encoding.Unicode;
					name = encoding.GetString(bb);
				}
				catch (System.Exception ex)
				{
					// fail silently
					name = "Error";
				}
			}
		}
		
		
		/// <summary> Constructs this object from the raw data
		/// 
		/// </summary>
		/// <param name="t">the raw data
		/// </param>
		/// <param name="biff7">a dummy value to tell the record to interpret the
		/// data as biff7
		/// </param>
		public BoundsheetRecord(Record t, Biff7 biff7):base(t)
		{
			sbyte[] data = getRecord().Data;
			offset = IntegerHelper.getInt(data[0], data[1], data[2], data[3]);
			typeFlag = data[5];
			visibilityFlag = data[4];
			length = data[6];
			sbyte[] bytes = new sbyte[length];
			Array.Copy(data, 7, bytes, 0, length);
			name = new string(ExcelUtils.Byte.ToCharArray(ExcelUtils.Byte.ToByteArray(bytes)));
		}
		static BoundsheetRecord()
		{
			biff7 = new Biff7();
		}
	}
}

⌨️ 快捷键说明

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