string filepath = @ "D:\data.xlsx"; string strConn = "provider= microsoft.ace.oledb.12.0; persist security info=false; " + "Data source=" + filepath + "; extended properties= ' excel 12.0; hdr=yes; imex=2 ' "; OleDbConnection con = new OleDbConnection (strconn); string excelsql = "select * from [data$] "; OleDbDataAdapter da = new OleDbDataAdapter (Excelsql, con); daTaset ds = new dataset (); da. Fill (DS); console.writeline (ds. Tables.count); console.writeline (ds. Tables[0]. Rows.Count); string conStr = "server=.; Database=test;uid=sa;pwd=123 "; stopwatch wt=new stopwatch ();          WT. Start (); using (sqlbulkcopy bulkcopy = New sqlbulkcopy (CONSTR)) { bulkcopy.destinationtablename = "_mobile"; //joins only one column, Then other repositories are implicitly empty. BULKCOPY.COLUMNMAPPINGS.ADD ("mobile", "mobile"); bulkcopy.bulkcopytimeout = 60 * 20; bulkcopy.batchsize = 100; bulkCopy.NotifyAfter = 100; bulkcopy.writetoserver (ds. Tables[0]); }   WT. Stop (); console.writeliNE ("time:>>" +WT. elapsedmilliseconds/1000+ "S");
Excel bulk data to SQL Server