I am trying to import an excel to database 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;

    //creating datacolumns
                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)
                    {
                        //error occured
                    }
                }

```

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 column names from all excel column names.