C# Class Smrf.AppLib.ExcelTableReader

Reads rows from an Excel table.
Use GetRows to iterate the rows of an Excel table. Filtered rows are automatically skipped, and the rows are buffered internally to eliminate having to make a slow COM interop call to get each row.

A collection of the column names in the table is available via the property.

Note that although this class is optimized for reading a table, the property allows you to write to the cells in a row as well. However, each such write operation incurs the overhead of a COM call, so this class should not be used when there are hundreds of cells that need to be written to.

Inheritance: Object
Show file Open project: 2014-sed-team3/term-project Class Usage Examples

Protected Properties

Property Type Description
m_aoCurrentSubrangeValues ].Object[
m_iCurrentRowOneBased System.Int32
m_oColumnIndexesOneBased Int32>.Dictionary
m_oCurrentSubrange Range
m_oTable ListObject

Public Methods

Method Description
ExcelTableReader ( ListObject table ) : System

Initializes a new instance of the ExcelTableReader class.

If table has hidden columns, an exception is thrown. Use the ExcelColumnHider class to temporarily show all hidden columns if necessary.

GetRows ( ) : IEnumerable

Protected Methods

Method Description
GetRangeForCellInCurrentRow ( String sColumnName ) : Range
TryGetDoubleFromCellInCurrentRow ( String sColumnName, Double &dDouble ) : System.Boolean
TryGetInt32FromCellInCurrentRow ( String sColumnName, Int32 &iInt32 ) : System.Boolean
TryGetNonEmptyStringFromCellInCurrentRow ( String sColumnName, String &sNonEmptyString ) : System.Boolean

Private Methods

Method Description
AssertValid ( ) : void

Method Details

ExcelTableReader() public method

Initializes a new instance of the ExcelTableReader class.
If table has hidden columns, an exception is thrown. Use the ExcelColumnHider class to temporarily show all hidden columns if necessary.
public ExcelTableReader ( ListObject table ) : System
table ListObject /// The table to read. The table must have no hidden columns. ///
return System

GetRangeForCellInCurrentRow() protected method

protected GetRangeForCellInCurrentRow ( String sColumnName ) : Range
sColumnName String
return Range

GetRows() public method

public GetRows ( ) : IEnumerable
return IEnumerable

TryGetDoubleFromCellInCurrentRow() protected method

protected TryGetDoubleFromCellInCurrentRow ( String sColumnName, Double &dDouble ) : System.Boolean
sColumnName String
dDouble Double
return System.Boolean

TryGetInt32FromCellInCurrentRow() protected method

protected TryGetInt32FromCellInCurrentRow ( String sColumnName, Int32 &iInt32 ) : System.Boolean
sColumnName String
iInt32 System.Int32
return System.Boolean

TryGetNonEmptyStringFromCellInCurrentRow() protected method

protected TryGetNonEmptyStringFromCellInCurrentRow ( String sColumnName, String &sNonEmptyString ) : System.Boolean
sColumnName String
sNonEmptyString String
return System.Boolean

Property Details

m_aoCurrentSubrangeValues protected property

protected Object[,] m_aoCurrentSubrangeValues
return ].Object[

m_iCurrentRowOneBased protected property

protected Int32,System m_iCurrentRowOneBased
return System.Int32

m_oColumnIndexesOneBased protected property

protected Dictionary m_oColumnIndexesOneBased
return Int32>.Dictionary

m_oCurrentSubrange protected property

protected Range m_oCurrentSubrange
return Range

m_oTable protected property

protected ListObject m_oTable
return ListObject