C#中将数据插入到Excel表中
C#中将数据插入到Excel表中
扫一扫加作者微信
想添加的数据就是下图表中的字段,在点击提交按钮的时候,将文本框中的值全部存进一个Excel表中,而且,没添加一次的时候,信息不覆盖,而是追加显示我感觉应该用读写文件的方式写,但是弄了半天没弄出来求大侠们帮帮忙,根据我提供的字段,给段代码谢谢了~~~~~~~
我写了上面的代码,但是这样无法实现让Execl有表头,还有就是这样写只能向储存.xls文件里存东西, 我想让他活一点,可以出来个OpenFileDialog选最好了 大侠们帮帮忙吧
C# Code:
string month = cboMonth.Text;
string day = cboDay.Text;
string bir = year "年" month "月" day "日";
string job = txtJob.Text;
string area = txtAddress.Text;
string email = txtEmail.Text;
string content = tel name bir job area email;
try
{
FileStream file = new FileStream("储存.xls", FileMode.Create,FileAccess.Write);
StreamWriter sw = new StreamWriter(file);
sw.WriteLine(content);
sw.Close();
file.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
//来源:C/S框架网(www.csframework.com) QQ:1980854898
string month = cboMonth.Text;
string day = cboDay.Text;
string bir = year "年" month "月" day "日";
string job = txtJob.Text;
string area = txtAddress.Text;
string email = txtEmail.Text;
string content = tel name bir job area email;
try
{
FileStream file = new FileStream("储存.xls", FileMode.Create,FileAccess.Write);
StreamWriter sw = new StreamWriter(file);
sw.WriteLine(content);
sw.Close();
file.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
//来源:C/S框架网(www.csframework.com) QQ:1980854898
扫一扫加作者微信
版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
NewDoc C/S框架网