using DevExpress.XtraGrid; using DevExpress.XtraGrid.Views.Grid; using DevExpress.XtraGrid.Columns; GridControl grid = new GridControl(); GridView view = new GridView(); grid.ForceInitialize(); //重要 grid.Dock = DockStyle.Fill; grid.ViewCollection.Add(view); grid.MainView = view; view.GridControl = grid; DataTable table = new DataTable(); table.Columns.Add("Name"); table.Rows.Add("Hello"); table.Rows.Add("World"); grid.DataSource = table; this.Controls.Add(grid);//重要 grid.BringToFront(); view.ExportToXls(@"c:\x.xls");