如何将DataView中的数据导入到Excel中,各位高手帮帮忙呀!
											请各位高手讲的详细点呀!如果有代码更好,将不胜感激。										
					
	
				
											看到代码,俺的心就凉了
  private void button1_Click(object sender, EventArgs e)
        {
            //调用自定义函数ExportDataGridview
            ExportDataGridview(dataGridView1, true);   
        }
        public bool ExportDataGridview(DataGridView dgv, bool isShowExcle)
        {
            if (dgv.Rows.Count == 0)
                return false;
            //建立Excel对象
         Excel.Application excel = new Excel.Application();
            
            excel.Application.Workbooks.Add(true);
            excel.Visible = isShowExcle;
            //生成字段名称
            for (int i = 0; i < dgv.ColumnCount; i++)
            {
              excel.Cells[1, i + 1] = dgv.Columns[i].HeaderText;
            }
            //填充数据
            for (int i = 0; i < dgv.RowCount - 1; i++)
            {
                for (int j = 0; j < dgv.ColumnCount; j++)
                {
                    if (dgv[j, i].ValueType == typeof(string))
                    {
                       excel.Cells[i + 2, j + 1] = "'" + dgv[j, i].Value.ToString();
                    }
                    else
                    {
                        excel.Cells[i + 2, j + 1] = dgv[j, i].Value.ToString();
                    }
                }
            }
            return true;
        }
你看看这个行吗?										
					
	
	
	
	      


											
	    

	