zoukankan      html  css  js  c++  java
  • mvvm Dev12.1 GridControl 导出

    此方法不适合12.1版本

    private void barExport_ItemClick(objectsender, DevExpress.XtraBars.ItemClickEventArgs e)

    {

        SaveFileDialog saveFileDialog =new SaveFileDialog();

        saveFileDialog.Title ="导出Excel";

        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);

            DevExpress.XtraEditors.XtraMessageBox.Show("保存成功!","提示", MessageBoxButtons.OK, MessageBoxIcon.Information);            }

    }

     

    12.1版本导出

     TableView dg = obj as TableView;
                if (dg != null)
                {
                    System.Windows.Forms.SaveFileDialog saveFileDialog = new System.Windows.Forms.SaveFileDialog();
                    saveFileDialog.DefaultExt = "*.xls";
                    saveFileDialog.AddExtension = true;
                    saveFileDialog.Filter = "Excel 文件|*.xls";
                    saveFileDialog.OverwritePrompt = true;
                    saveFileDialog.CheckPathExists = true;
                    if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK && saveFileDialog.FileName != null)
                    {
                        string fileName = saveFileDialog.FileName;//文件名字
                        DevExpress.XtraPrinting.XlsExportOptions options = new DevExpress.XtraPrinting.XlsExportOptions(DevExpress.XtraPrinting.TextExportMode.Value);
                        dg.ExportToXls(fileName, options);
                        MessageBox.Show("报表导出成功!", "系统提示");
                    }
                }

  • 相关阅读:
    通过HttpListener实现简单的Http服务
    WCF心跳判断服务端及客户端是否掉线并实现重连接
    NHibernate初学六之关联多对多关系
    NHibernate初学五之关联一对多关系
    EXTJS 4.2 资料 跨域的问题
    EXTJS 4.2 资料 控件之Grid 那些事
    EXTJS 3.0 资料 控件之 GridPanel属性与方法大全
    EXTJS 3.0 资料 控件之 Toolbar 两行的用法
    EXTJS 3.0 资料 控件之 combo 用法
    EXTJS 4.2 资料 控件之 Store 用法
  • 原文地址:https://www.cnblogs.com/swarb/p/9924307.html
Copyright © 2011-2022 走看看