读书人

导出dataGridView 的数据到EXCEL 中,该

发布时间: 2012-06-06 16:44:11 作者: rapoo

导出dataGridView 的数据到EXCEL 中

private void button2_Click(object sender, EventArgs e)
{
Productdiscount pd = new Productdiscount();
Serviceinformation si = new Serviceinformation();
if (MessageBox.Show("您确定要导出吗?", "提示",
MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
{
ExportDate ep = new ExportDate();
ep.dgvOutPutExcel(dataGridView1);这个有值
ep.dgvOutPutExcel(pd.dataGridView1);我断点看了这个没有值
ep.dgvOutPutExcel(si.dataGridView1);我断点看了这个没有值
这是为什么。知道的代码简略打下


}

[解决办法]
Productdiscount pd = new Productdiscount();
Serviceinformation si = new Serviceinformation();

你这里new了两个新的对象,新对象里面的dataGridView和已经有数据的dataGridView不是一个
[解决办法]

探讨
不是一个的,Productdiscount();有一个
Serviceinformation();也有一个。都不是一养的

读书人网 >C#

热点推荐