windows窗體上放了一個Textbox1,2個按鈕button1和button2~按button1選擇excel文件~按button2進行相關處理
Code Snippet
private void button1_click(object sendeer,EventArgs e)
{
OpenFileDialog openFiledialog1=new OpenFileDialog();
openFileDialg1.filter="Excel文件|*.xls";
openFileDialg1.ShowDialog();
textBox1.Text=openFileDialog1.FileName;
}
private void button2_click(object sender, EventArg e)
{
DataSet dt=ReadExcel(textBox1.Text);
//然後進行您需要的數據處理
}