zoukankan      html  css  js  c++  java
  • WinForm------如何将GridControl数据导出到Excel

    转载:

    http://www.cnblogs.com/xiaofengfeng/archive/2011/11/22/2258906.html

    Gridcontrol中的BandedGridView导出多层行头

    转载:

    http://www.cnblogs.com/huldy520/p/5611736.html 

    代码:

    protected virtual void ExportToExcel(Object grid)
    {
      //EditorContainer定义GridControl之类的容器
      SaveFileDialog dialog = new SaveFileDialog
      {
        Title = "导出Excel",
        Filter = "Excel文件(*.xls)|*.xls"
      };
      if (dialog.ShowDialog(this) == DialogResult.OK)
      {
        //XlsExportOptions
        XlsExportOptionsEx options = new XlsExportOptionsEx();
        if (grid is GridControl)
        {
          (grid as GridControl).ExportToXls(dialog.FileName, options);
        }
        else if (grid is BandedGridView)
        {
          options.ExportType = DevExpress.Export.ExportType.WYSIWYG;
          (grid as BandedGridView).OptionsPrint.AutoWidth = false;
          (grid as BandedGridView).OptionsPrint.PrintBandHeader = true;
          (grid as BandedGridView).ExportToXls(dialog.FileName, options);
        }
        else if (grid is TreeList)
        {
          (grid as TreeList).ExpandAll();
          (grid as TreeList).ExportToXls(dialog.FileName, options);
        }
        XtraMessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
      }
    }
  • 相关阅读:
    ASP.NET MVC中你必须知道的13个扩展点
    ASP.NET MVC扩展库
    AutoFac简介
    中小型研发团队架构实践十:应用监控怎么做?
    IDEA+Mybatis-generator代码生成工具
    IDEA+EasyCode实现代码生成
    myeclipse中导入的js文件报错(出现红叉叉,提示语法错误)
    Ibatis中常见错误解决方案
    注解
    structs常见错误
  • 原文地址:https://www.cnblogs.com/tianhengblogs/p/6084465.html
Copyright © 2011-2022 走看看