GridControl 导出Excel功能
using DevExpress.Utils;using DevExpress.XtraEditors;
using DevExpress.XtraGrid;
using DevExpress.XtraGrid.Columns;
using DevExpress.XtraGrid.Views.Base;
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraGrid.Views.Grid.ViewInfo;
private void ExportAll()
{
if (this.gridView1.DataRowCount > 0)
{
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.Title = "导出Excel";
saveFileDialog.Filter = "Excel文件(*.xls)|*.xls";
saveFileDialog.FileName = DateTime.Now.ToString().Replace(":", "-") + "导出信息";
DialogResult dialogResult = saveFileDialog.ShowDialog(this);
if (dialogResult == DialogResult.OK)
{
gridControl1.ExportToXls(saveFileDialog.FileName);
XtraMessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
else
{
XtraMessageBox.Show("没有数据,系统无法为你导出信息!");
}
}
页:
[1]