使用DEV GridControl导出 DataTable

来源:互联网 发布:ipad淘宝横屏版 编辑:程序博客网 时间:2024/05/17 09:34
                DevExpress.XtraGrid.GridControl gridResult = new DevExpress.XtraGrid.GridControl();                DevExpress.XtraGrid.Views.Grid.GridView gvwResult = new DevExpress.XtraGrid.Views.Grid.GridView();                gridResult.MainView = gvwResult;                               gridResult.DataSource = table;                //the grid contorl be added to a form ,otherwise a empty table will be exported                System.Windows.Forms.Form a = new System.Windows.Forms.Form();                a.Controls.Add(gridResult);                                               gvwResult.BestFitColumns();                gridResult.ExportToXls(file);


需要把GridControl添加到Form中 才能成功导出。Form并不用显示出来 

0 0
原创粉丝点击