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

📄 sharedformulacellreference.cs

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

using Microsoft.Fawvw.Components.NExcel.Biff;

namespace Microsoft.Fawvw.Components.NExcel.Biff.Formula
{
	
	/// <summary> A cell reference in a formula</summary>
	class SharedFormulaCellReference:Operand, ParsedThing
	{
		virtual public int Column
		{
			get
			{
				return column;
			}
			
		}
		virtual public int Row
		{
			get
			{
				return row;
			}
			
		}
		/// <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.REF.Code;
				
				IntegerHelper.getTwoBytes(row, data, 1);
				
				int columnMask = column;
				
				if (columnRelative)
				{
					columnMask |= 0x4000;
				}
				
				if (rowRelative)
				{
					columnMask |= 0x8000;
				}
				
				IntegerHelper.getTwoBytes(columnMask, data, 3);
				
				return data;
			}
			
		}
		/// <summary> Indicates whether the column reference is relative or absolute</summary>
		private bool columnRelative;
		
		/// <summary> Indicates whether the row reference is relative or absolute</summary>
		private bool rowRelative;
		
		/// <summary> The column reference</summary>
		private int column;
		
		/// <summary> The row reference</summary>
		private int row;
		
		/// <summary> The cell containing the formula.  Stored in order to determine
		/// relative cell values
		/// </summary>
		private Cell relativeTo;
		
		/// <summary> Constructor
		/// 
		/// </summary>
		/// <param name="the">cell the formula is relative to
		/// </param>
		public SharedFormulaCellReference(Cell rt)
		{
			relativeTo = rt;
		}
		
		/// <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)
		{
			// Preserve signage on column and row values, because they will
			// probably be relative
			row = IntegerHelper.getShort(data[pos], data[pos + 1]);
			
			int columnMask = IntegerHelper.getInt(data[pos + 2], data[pos + 3]);
			
			column = (sbyte) (columnMask & 0xff);
			columnRelative = ((columnMask & 0x4000) != 0);
			rowRelative = ((columnMask & 0x8000) != 0);
			
			if (columnRelative)
			{
				column = relativeTo.Column + column;
			}
			
			if (rowRelative)
			{
				row = relativeTo.Row + row;
			}
			
			return 4;
		}
		
		public override void  getString(System.Text.StringBuilder buf)
		{
			CellReferenceHelper.getCellReference(column, row, buf);
		}
	}
}

⌨️ 快捷键说明

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