Showing posts with label Ms Office 2007 Oledb Read file Excel Code and 2010 code. Show all posts
Showing posts with label Ms Office 2007 Oledb Read file Excel Code and 2010 code. Show all posts

Wednesday, June 18, 2014

Ms Office 2007 Oledb Read file Excel Code and 2010 code

2007................
OleDbConnection con = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source='E://Naresh.xlsx';Extended Properties=\'Excel 8.0';");

     
        OleDbCommand cmd = new OleDbCommand("select * from [Sheet1$]");
        cmd.Connection = con;
        OleDbDataAdapter dap = new OleDbDataAdapter(cmd);
        DataSet ds = new DataSet();
        dap.Fill(ds);
        return (ds);
2010..................
OleDbConnection con = new OleDbConnection("Provider=Microsoft.JET.OLEDB.4.0;Data Source='E://Naresh.xlsx';Extended Properties=\'Excel 8.0';");

     
        OleDbCommand cmd = new OleDbCommand("select * from [Sheet1$]");
        cmd.Connection = con;
        OleDbDataAdapter dap = new OleDbDataAdapter(cmd);
        DataSet ds = new DataSet();
        dap.Fill(ds);
        return (ds);