Excel Data

The second method is by using office interop , If you want to get excel data in c# you can get it by using office interop object  , excel data then can be used or transferred any were.

METHOD II

      public static System.Data.DataTable GetExcelData(string _path)
        {


            System.Data.DataTable ExcelData = new System.Data.DataTable();
            ExcelData.Columns.Add(new DataColumn(“ProductName”, typeof(string)));
           


            Excel.Application xlApp = new Excel.ApplicationClass();
            Excel._Workbook xlWorkbook = xlApp.Workbooks.Open(_path);
            Excel._Worksheet xlWorksheet = (Excel.Worksheet)xlWorkbook.Sheets.get_Item(1);
            Excel.Range xlRange = xlWorksheet.UsedRange;




            for (int r = 2; r < = xlRange.Rows.Count; r++)
            {
                DataRow _r = ExcelData.NewRow();


                _r[0] = (xlRange.Cells[r, 1] as Excel.Range).Value2.ToString();


                ExcelData.Rows.Add(_r);
            }


            xlWorkbook.Close(true, Type.Missing, Type.Missing);
            xlApp.Quit();


            return ExcelData;
        }