Okay,
i'll try to explain myself clear with the problem i'm having right now, i'm sure it has a very simple solution i'm just not seeing it right now, (could be the time of day or lack of coffee, anyways)
I am writing a little winforms program for our product managers in our company so that they can import any given excel file with data about products in each column (like name, description, material etc..) and i want my program to read the colum names, which i already have see snipet:
private Excel.Application appExl;
private Excel.Workbook workbook;
private Excel.Worksheet NwSheet;
private Excel.Range ShtRange;
private Webproduct Articulo;
private List<Webproduct> Articulos;
private Excel.ApplicationClass appXl;
if (ofdExcel.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
string filename = ofdExcel.FileName;
workbook = appXl.Workbooks.Open(filename, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
NwSheet = (Excel.Worksheet)workbook.Sheets.get_Item(1);
int Cnum = 0;
int Rnum = 0;
ShtRange = NwSheet.UsedRange;
Hashtable htColumns = new Hashtable();
for (int i = 1; i <= ShtRange.Columns.Count; i++)
{
htColumns.Add(i, ((Range)ShtRange.Cells[1, i]).Value2);
}
}
Okay so i thought i have a webproduct class which has all the field requiered by our product database, some of them like (id, language, Reference,etc..) are mandatory and some others optional(dimensions, material, whatsoever)
what i want to do is that once the column names are in the Hashtable (don't know if that is the best way to do it) how can i associate or what would be the best way to associate the excel column names with the webproduct columns,
Example i know my webproduct has the variable _ProductName but the excel file colum could be "ProductName" or "Nombre" or "Whatever"
What kind of solution would you do? i'm not asking for the complete code just a hint to the right direction or maybe a snippet to make this as dynamic as possible knowing that the are about 86 columns/variables
any ideas?