2

I have created an attendance sheet in excel and i want to display all sheets like class attendance report,students attendance report etc in gridview,can anybody help me?

Ashraf Ali
  • 37
  • 1
  • 5

2 Answers2

0

You should import your sheets into a DataSet object, and then bind it to a GridView.
Take a look at those links:
Excel Sheet to DataSet: link_1
Bind DataSet to Gridview: link_2

Community
  • 1
  • 1
Omer Eldan
  • 1,757
  • 1
  • 11
  • 10
0
   List<string> excelName = new List<string>();   
   DataSet ds = new DataSet();  
   foreach(var name in excelName )
    {
        using (SqlConnection con = new SqlConnection(connectionString))
        {        
            DataTable dt = new DataTable();
            string query ="select * from '"+name+"'";
            con.Open();
            SqlDataAdapter da = new OleDbDataAdapter(query, con);
            da.Fill(dt);
            con.Close();    
            ds.add(dt);            
        }
    }

    gridview.DataSource = ds;
    gridview.DataBind();
Omer Eldan
  • 1,757
  • 1
  • 11
  • 10
Suraj Singh
  • 4,041
  • 1
  • 21
  • 36
  • If i supposed to select this file from my system and on button click i wanna see,where i have to write this code? – Ashraf Ali Dec 06 '13 at 06:58
  • @user3069405 You can have a look at this http://stackoverflow.com/questions/17568604/import-excel-data-to-datagridview-in-visual-studio-2010 – Suraj Singh Dec 06 '13 at 07:10