booleanvalue.cs

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

CS
76
字号
using System;

using Microsoft.Fawvw.Components.NExcel.Biff;

namespace Microsoft.Fawvw.Components.NExcel.Biff.Formula
{
	
	/// <summary> A boolean operand in a formula</summary>
	class BooleanValue: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[2];
				data[0] = Token.BOOL.Code;
				data[1] = (sbyte) (Value == true?1:0);
				
				return data;
			}
			
		}
		/// <summary> The boolean value</summary>
		private bool Value;
		
		/// <summary> Constructor</summary>
		public BooleanValue()
		{
		}
		
		/// <summary> Constructor used when parsing a string formula
		/// 
		/// </summary>
		/// <param name="s">the string token, including quote marks
		/// </param>
		public BooleanValue(string s)
		{
			// remove the quotes
			Value = System.Boolean.Parse(s);
		}
		
		
		/// <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)
		{
			Value = data[pos] == 1?true:false;
			return 1;
		}
		
		/// <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(Value.ToString());
			
		}
	}
}

⌨️ 快捷键说明

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