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

📄 namerange.cs

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

using Microsoft.Fawvw.Components.NExcel.Biff;

namespace Microsoft.Fawvw.Components.NExcel.Biff.Formula
{
	
	/// <summary> A name operand</summary>
	class NameRange:Operand, ParsedThing
	{
		/// <summary> Gets the token representation of this item in RPN
		/// 
		/// </summary>
		/// <returns> the bytes applicable to this formula
		/// </returns>
		override internal sbyte[] Bytes
		{
			get
			{
				sbyte[] data = new sbyte[5];
				data[0] = Token.NAMED_RANGE.Code;
				
				IntegerHelper.getTwoBytes(index, data, 1);
				
				return data;
			}
			
		}
		/// <summary> A handle to the name table</summary>
		private WorkbookMethods nameTable;
		
		/// <summary> The string name</summary>
		private string name;
		
		/// <summary> The index into the name table</summary>
		private int index;
		
		/// <summary> Constructor</summary>
		public NameRange(WorkbookMethods nt)
		{
			nameTable = nt;
		}
		
		/// <summary> Constructor when parsing a string via the api
		/// 
		/// </summary>
		/// <param name="nm">the name string
		/// </param>
		/// <param name="nt">the name table
		/// </param>
		public NameRange(string nm, WorkbookMethods nt)
		{
			name = nm;
			nameTable = nt;
			
			index = nameTable.getNameIndex(name);
			
			if (index < 0)
			{
				throw new FormulaException(FormulaException.cellNameNotFound, name);
			}
			
			index += 1; // indexes are 1-based
		}
		
		/// <summary> Reads the ptg data from the array starting at the specified position
		/// 
		/// </summary>
		/// <param name="data">the RPN array
		/// </param>
		/// <param name="pos">the current position in the array, excluding the ptg identifier
		/// </param>
		/// <returns> the number of bytes read
		/// </returns>
		public virtual int read(sbyte[] data, int pos)
		{
			index = IntegerHelper.getInt(data[pos], data[pos + 1]);
			
			name = nameTable.getName(index - 1); // ilbl is 1-based
			
			return 4;
		}
		
		/// <summary> Abstract method implementation to get the string equivalent of this
		/// token
		/// 
		/// </summary>
		/// <param name="buf">the string to append to
		/// </param>
		public override void  getString(System.Text.StringBuilder buf)
		{
			buf.Append(name);
		}
	}
}

⌨️ 快捷键说明

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