一种迅速从datatable生成excel文件的方法
System.Windows.Forms.SaveFileDialog save = new SaveFileDialog();
save.CheckPathExists = true;
save.Filter = "数据文件(*.xls)|*.xls";
save.DefaultExt = "xls";
save.Title = "保存当前数据";
if(save.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
System.Data.DataSet ds = (System.Data.DataSet)(ugXiangmu.DataSource);
this.ugXiangmu.SetDataBinding(this.dgJianpin.DataSource,"");//需要用插件UltraWinGrid.UltraGrid ugXiangmu
this.ultraGridExcelExporter1.Export(this.ugXiangmu,save.FileName); //需要用插件ultraGridExcelExporter同上。
}