I am trying to import an excel to databse from asp.net website through dataset.
here is my first part.
int xlColCount = 1;
wb = app.Workbooks.Open(FilePath, 0, false, 5, "", "", true, Ex.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
ws = (Ex.Worksheet)wb.ActiveSheet;
xlColCount = ws.Columns.Count;
xlColCount = ws.UsedRange.Columns.Count;
ws.Columns.ClearFormats();
xlColCount = ws.UsedRange.Columns.Count;
for (int i = 0; i < xlColCount; i++)
{
try
{
DSname.Tables[0].Columns.Add(((Ex.Range)ws.Cells[1,strColArr[i]]).Value2.ToString().Trim());
}
catch(Exception ex)
{
}
}
first i am creating the column name based on the excel heading into dataset column.here xlColCount=198(total no.of columns from the excel template and all are filled ) but when reaching 172th column(i=172) it is giving index out of range error.
what could be the reason.I need to create a dataset with coulmn names from all excel coulmn names.
Anyone pls help it is urgent....