errorformularecord.cs
来自「Excel的操作,其中可以读取及写入Excel 文件」· CS 代码 · 共 134 行
CS
134 行
using System;
using Microsoft.Fawvw.Components.NExcel.ExcelCommon;
using Microsoft.Fawvw.Components.NExcel.Biff;
using Microsoft.Fawvw.Components.NExcel.Biff.Formula;
namespace Microsoft.Fawvw.Components.NExcel.Read.Biff
{
/// <summary> An error resulting from the calculation of a formula</summary>
class ErrorFormulaRecord:CellValue, ErrorCell, FormulaData, ErrorFormulaCell
{
/// <summary> Interface method which gets the error code for this cell. If this cell
/// does not represent an error, then it returns 0. Always use the
/// method isError() to determine this prior to calling this method
///
/// </summary>
/// <returns> the error code if this cell contains an error, 0 otherwise
/// </returns>
virtual public int ErrorCode
{
get
{
return errorCode;
}
}
/// <summary> Returns the numerical value as a string
///
/// </summary>
/// <returns> The numerical value of the formula as a string
/// </returns>
virtual public string Contents
{
get
{
return "ERROR " + errorCode;
}
}
/// <summary> Returns the cell type
///
/// </summary>
/// <returns> The cell type
/// </returns>
virtual public CellType Type
{
get
{
return CellType.FORMULA_ERROR;
}
}
/// <summary> Gets the formula as an excel string
///
/// </summary>
/// <returns> the formula as an excel string
/// </returns>
/// <exception cref=""> FormulaException
/// </exception>
virtual public string Formula
{
get
{
if ((System.Object) formulaString == null)
{
sbyte[] tokens = new sbyte[data.Length - 22];
Array.Copy(data, 22, tokens, 0, tokens.Length);
FormulaParser fp = new FormulaParser(tokens, this, externalSheet, nameTable, Sheet.Workbook.Settings);
fp.parse();
formulaString = fp.Formula;
}
return formulaString;
}
}
/// <summary> The error code of this cell</summary>
private int errorCode;
/// <summary> A handle to the class needed to access external sheets</summary>
private ExternalSheet externalSheet;
/// <summary> A handle to the name table</summary>
private WorkbookMethods nameTable;
/// <summary> The formula as an excel string</summary>
private string formulaString;
/// <summary> The raw data</summary>
private sbyte[] data;
/// <summary> Constructs this object from the raw data
///
/// </summary>
/// <param name="t">the raw data
/// </param>
/// <param name="fr">the formatting records
/// </param>
/// <param name="es">the external sheet
/// </param>
/// <param name="nt">the name table
/// </param>
/// <param name="si">the sheet
/// </param>
public ErrorFormulaRecord(Record t, FormattingRecords fr, ExternalSheet es, WorkbookMethods nt, SheetImpl si):base(t, fr, si)
{
externalSheet = es;
nameTable = nt;
data = getRecord().Data;
Assert.verify(data[6] == 2);
errorCode = data[8];
}
/// <summary> Gets the raw bytes for the formula. This will include the
/// parsed tokens array
///
/// </summary>
/// <returns> the raw record data
/// </returns>
public virtual sbyte[] getFormulaData()
{
// Lop off the standard information
sbyte[] d = new sbyte[data.Length - 6];
Array.Copy(data, 6, d, 0, data.Length - 6);
return d;
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?