谢谢了先
谢谢了先
我只知道怎么样从Excel文件里面读出来。按纽事件里面写:
try
{
string strCon = " Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source = E:\\工作区\\公司项目\\学籍管理系统\\学籍管理系统CODE\\OutToExcel\\OutToExcel\\bin\\成绩.xls;Extended Properties=Excel 8.0";
OleDbConnection myConn = new OleDbConnection(strCon);
string strCom = " SELECT * FROM [Sheet1$] ";
myConn.Open();
OleDbDataAdapter myCommand = new OleDbDataAdapter(strCom, myConn);
DataSet myDataSet = new DataSet();
myCommand.Fill(myDataSet, "[Sheet1$]");
dataGridView1.DataSource = myDataSet.Tables[0];
myConn.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
就可以了,其余的自己去改。