footleg

导航

一种迅速从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同上。      
            }


 

posted on 2010-12-02 15:06  迷途  阅读(388)  评论(0编辑  收藏  举报