private void button1_Click(object sender, EventArgs e)//浏览 { OpenFileDialog open = new OpenFileDialog(); open.Title = "请选择要导入的Excel文件"; open.Filter = "XLSX 工作表 (*.xlsx)|*.xlsx|Excel表(*.xls)|*.xls"; if (open.ShowDialog() == DialogResult.OK) { string fileName = open.FileName; textBox1.Text = fileName; ad_ServicesBLL bLL = new ad_ServicesBLL(); // string sql = "select * from Student"; DataTable dataTable = bLL.importToExcel(fileName); bLL.DataTableToStuSQLServerbll(dataTable); dataGridView1.DataSource = bLL.importToExcel(fileName); } }
private void button1_Click(object sender, EventArgs e)//导入 { OpenFileDialog open = new OpenFileDialog(); open.Title = "请选择要导入的Excel文件"; open.Filter = "XLSX 工作表 (*.xlsx)|*.xlsx|Excel表(*.xls)|*.xls"; if (open.ShowDialog() == DialogResult.OK) { string fileName = open.FileName; textBox1.Text = fileName; ad_ServicesBLL bLL = new ad_ServicesBLL(); DataTable dataTable = bLL.importToExcel(fileName); bLL.DataTableToTeaSQLServerbll(dataTable); Teagridview.DataSource = dataTable; } }