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("报表导出成功!", "系统提示");
                    }
                }

  • 相关阅读:
    Android之TabHost实现Tab切换
    银联支付SDK集成
    iOS 支付 [支付宝、银联、微信]
    MySQL数据库数据类型以及INT(M)的含义
    cherrypy
    使用PyMySQL操作mysql数据库
    面向新手的Web服务器搭建(一)——IIS的搭建
    SQLite3中自增主键相关知识总结,清零的方法、INTEGER PRIMARY KEY AUTOINCREMENT和rowid的使用
    FMDB-FMDatabaseQueue
    SQLite 数据类型
  • 原文地址:https://www.cnblogs.com/swarb/p/9924307.html