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并不用显示出来