Member 12809742
public static Dictionary<string,int> GetColumnMapping(Excel.Worksheet ExcelSheet, int HeaderRowIndex , List<string> Headers, Dictionary<string,int> HeaderMapping)
{
if (HeaderMapping != null)
HeaderMapping.Clear();
object misValue = System.Reflection.Missing.Value;
Excel.Range HeaderRange = ExcelSheet.Rows[HeaderRowIndex , misValue];
Excel.Range currentFind = null;
foreach (string Header in Headers)
{
currentFind = HeaderRange.Find(Header, misValue, Excel.XlFindLookIn.xlValues, Excel.XlLookAt.xlPart, Excel.XlSearchOrder.xlByColumns, Excel.XlSearchDirection.xlNext, false, misValue, misValue);
if(currentFind != null)
HeaderMapping.Add(Header, currentFind.Column);
}
return HeaderMapping;
}