你完全可以把Excel当数据表一样读出来,然后再写进Sql
读Excel的方法:
string strConn = "provider=Microsoft.Jet.OLEDB.4.0;data source=Excel文件;Extended Properties=Excel 8.0;";
OleDbConnection oleConn = new OleDbConnection(strConn);
oleConn.Open();
string olestr = "select * from [Sheet1$]";
OleDbCommand oleComm = new OleDbCommand(olestr, oleConn);
oleComm.Connection = oleConn;
OleDbDataAdapter oleDa = new OleDbDataAdapter();
oleDa.SelectCommand = oleComm;
DataSet ds = new DataSet();
oleDa.Fill(ds);
foreach (DataRow row in ds.Tables["INFO"].Rows)
{
string userInfo = row[0].ToString().Trim();
}
oleConn.Close();