如何将多个工作表中的数据复制到数据网格视图中。目前我从1张纸上复印如下:
string SheetName = this.cmbSheetNames.SelectedText.ToString();
System.Data.OleDb.OleDbDataAdapter MyCommand =
new System.Data.OleDb.OleDbDataAdapter("SELECT * FROM [" + SheetName + "$]", objConn);
MyCommand.Fill(DS);
object Dt4 = DS.Tables[0];
dgvUploads.DataSource = Dt4;
答案 0 :(得分:0)
string SheetName = this.cmbSheetNames.SelectedText.ToString();
System.Data.OleDb.OleDbDataAdapter MyCommand = new System.Data.OleDb.OleDbDataAdapter("SELECT * FROM [" + SheetName + "$]", objConn);
System.Data.OleDb.OleDbDataReader reader = MyCommand.ExecuteReader();
dgvUploads.DataSource = reader;
dgvUploads.DataBind();