📄 stringvalue.cs
字号:
using System;
using Microsoft.Fawvw.Components.NExcel.Biff;
namespace Microsoft.Fawvw.Components.NExcel.Biff.Formula
{
/// <summary> A string constant operand in a formula</summary>
class StringValue: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[Value.Length * 2 + 3];
data[0] = Token.STRING.Code;
data[1] = (sbyte) (Value.Length);
data[2] = (sbyte) (0x01);
StringHelper.getUnicodeBytes(Value, data, 3);
return data;
}
}
/// <summary> The string value</summary>
private string Value;
/// <summary> The workbook settings</summary>
private WorkbookSettings settings;
/// <summary> Constructor</summary>
public StringValue(WorkbookSettings ws)
{
settings = ws;
}
/// <summary> Constructor used when parsing a string formula
///
/// </summary>
/// <param name="s">the string token, including quote marks
/// </param>
public StringValue(string s)
{
// remove the quotes
Value = 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)
{
int length = data[pos];
int consumed = 2;
if ((data[pos + 1] & 0x01) == 0)
{
Value = StringHelper.getString(data, length, pos + 2, settings);
consumed += length;
}
else
{
Value = StringHelper.getUnicodeString(data, length, pos + 2);
consumed += length * 2;
}
return consumed;
}
/// <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("\"");
buf.Append(Value);
buf.Append("\"");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -