rkrecord.cs

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

CS
115
字号
using System;

using Microsoft.Fawvw.Components.NExcel.ExcelUtils;
using Microsoft.Fawvw.Components.NExcel.Biff;

namespace Microsoft.Fawvw.Components.NExcel.Read.Biff
{
	
	/// <summary> An individual RK record</summary>
	class RKRecord:CellValue, NumberCell
	{
		/// <summary> Accessor for the value
		/// 
		/// </summary>
		/// <returns> the value
		/// </returns>
		virtual public double DoubleValue
		{
			get
			{
				return _Value;
			}
		}

		/// <summary>
		/// Returns the value.
		/// </summary>
		virtual public object Value
		{
			get
			{
				return this._Value;
			}
		}

		/// <summary> Returns the contents of this cell as a string
		/// 
		/// </summary>
		/// <returns> the value formatted into a string
		/// </returns>
		virtual public string Contents
		{
			get
			{
				// [TODO-NExcel_Next] find a better way
//				return _Value.ToString(format);
				return string.Format(format, "{0}", _Value);
			}
			
		}
		/// <summary> Accessor for the cell type
		/// 
		/// </summary>
		/// <returns> the cell type
		/// </returns>
		virtual public CellType Type
		{
			get
			{
				return CellType.NUMBER;
			}
			
		}
		/// <summary> Gets the NumberFormatInfo used to format this cell.  This is the java
		/// equivalent of the Excel format
		/// 
		/// </summary>
		/// <returns> the NumberFormatInfo used to format the cell
		/// </returns>
		virtual public NumberFormatInfo NumberFormat
		{
			get
			{
				return format;
			}
			
		}
		/// <summary> The value</summary>
		private double _Value;
		
		/// <summary> The java equivalent of the excel format</summary>
		new private NumberFormatInfo format;
		
		/// <summary> The formatter to convert the value into a string</summary>
		private static NumberFormatInfo defaultFormat;
		
		/// <summary> Constructs this object from the raw data
		/// 
		/// </summary>
		/// <param name="t">the raw data
		/// </param>
		/// <param name="fr">the available cell formats
		/// </param>
		/// <param name="si">the sheet
		/// </param>
		public RKRecord(Record t, FormattingRecords fr, SheetImpl si):base(t, fr, si)
		{
			sbyte[] data = getRecord().Data;
			int rknum = IntegerHelper.getInt(data[6], data[7], data[8], data[9]);
			_Value = RKHelper.getDouble(rknum);
			
			// Now get the number format
			format = fr.getNumberFormat(XFIndex);
			if (format == null)
			{
				format = defaultFormat;
			}
		}
		static RKRecord()
		{
			defaultFormat = new NumberFormatInfo("#.###");
		}
	}
}

⌨️ 快捷键说明

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