本文实例讲述了C#窗体读取EXCEL并存入SQL数据库的方法。分享给大家供大家参考。具体实现方法如下:
windows窗体上放了一个Textbox1,2个按钮button1和button2~按button1选择excel文件~按button2进行相关处理
代码如下:
private void button1_click(object sendeer,EventArgs e)
{
OpenFileDialog openFiledialog1=new OpenFileDialog();
openFileDialg1.filter=”Excel文件|*.xls”;
openFileDialg1.ShowDialog();
textBox1.Text=openFileDialog1.FileName;
}
{
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);
//然后进行您需要的数据处理
}
除声明外,跑步客文章均为原创,转载请以链接形式标明本文地址
C#窗体读取EXCEL并存入SQL数据库的方法
本文地址: http://www.paobuke.com/develop/c-develop/pbk23190.html
C#窗体读取EXCEL并存入SQL数据库的方法
本文地址: http://www.paobuke.com/develop/c-develop/pbk23190.html