首先要用代码设置gridView的属性,如过数据是代码生成的,直接在GridView的RunDesign中设计是没用的
GridView1.OptionsSelection.MultiSelect =true;GridView1.OptionsPRint.PrintSelectedRowsOnly=true; SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Title = "导出Excel"; saveFileDialog.Filter = "Excel文件(*.pdf)|*.pdf"; saveFileDialog.Filter = "Excel文件(*.xls)|*.xls"; DialogResult dialogResult = saveFileDialog.ShowDialog(this); if (dialogResult == DialogResult.OK) { DevExpress.XtraPrinting.XlsExportOptions options = new DevExpress.XtraPrinting.XlsExportOptions(); gridControl1.ExportToXls(saveFileDialog.FileName, options); DevExpress.XtraEditors.XtraMessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); }新闻热点
疑难解答