GetRowIDDictionary
(
ListObject oTable,
String sColumnName
)
{
Debug.Assert(oTable != null);
Debug.Assert( !String.IsNullOrEmpty(sColumnName) );
Dictionary<Int32, Object> oRowIDDictionary =
new Dictionary<Int32, Object>();
// The code that reads the table can handle hidden rows, but not hidden
// columns. Temporarily show all hidden columns in the table.
ExcelHiddenColumns oHiddenColumns =
ExcelColumnHider.ShowHiddenColumns(oTable);
try
{
ExcelTableReader oExcelTableReader = new ExcelTableReader(oTable);
foreach ( ExcelTableReader.ExcelTableRow oRow in
oExcelTableReader.GetRows() )
{
Int32 iRowID;
Double dCellValue;
if (
oRow.TryGetInt32FromCell(CommonTableColumnNames.ID,
out iRowID)
&&
oRow.TryGetDoubleFromCell(sColumnName, out dCellValue)
)
{
oRowIDDictionary[iRowID] = dCellValue;
}
}
}
finally
{
ExcelColumnHider.RestoreHiddenColumns(oTable, oHiddenColumns);
}
return (oRowIDDictionary);
}