• Gridview导出EXCEL(多页) z


    using System;
    
    using System.Collections.Generic;
    
    using System.ComponentModel;
    
    using System.Data;
    
    using System.Drawing;
    
    using System.IO;
    
    using DevExpress.XtraGrid.Views.BandedGrid;
    
    using DevExpress.XtraPrintingLinks;
    
    using DevExpress.XtraPrinting;
    
    
    
    private void Form1_Load(object sender, EventArgs e)
    
    {
    
    DataTable dt1 = new DataTable();
    
    dt1.Columns.Add("a1");
    
    dt1.Columns.Add("a2");
    
    dt1.Columns.Add("a3");
    
    dt1.Columns.Add("a4");
    
    
    
    DataTable dt2 = dt1.Copy();
    
    dt1.Rows.Add("A", "22222", "22222", "22222");
    
    dt1.Rows.Add("B", "33333333333", "33333333333", "3");
    
    dt1.Rows.Add("C", "12", "24", "3");
    
    
    
    dt2.Rows.Add("AA", "1", "1", "3");
    
    dt2.Rows.Add("AA", "222", "555", "3");
    
    dt2.Rows.Add("BB", "12", "24", "3");
    
    dt2.Rows.Add("BB", "13", "22222", "3");
    
    gridControl1.DataSource = dt1;
    
    gridControl3.DataSource = dt2;
    
    }
    
    
    
    private void Btn_Excel_Click(object sender, EventArgs e)
    
    {
    
    CompositeLink complink = new CompositeLink(new PrintingSystem());
    
    
    
    PrintableComponentLink link = new PrintableComponentLink();
    
    link.Component = gridControl1;
    
    PrintableComponentLink link2 = new PrintableComponentLink();
    
    link2.Component = gridControl3;
    
    
    
    complink.Links.Add(link);
    
    complink.Links.Add(link2);
    
    
    
    complink.CreatePageForEachLink();
    
    complink.ExportToXlsx("file1.xlsx", new XlsxExportOptions() { ExportMode = XlsxExportMode.SingleFilePageByPage });
    
    }
    

     


  • 相关阅读:
    bzoj 2456 mode
    codeforces 630 I(规律&&组合)
    codeforces 630H (组合数学)
    codeforces 651A Joysticks
    codeforces 651B Beautiful Paintings
    codeforces 625C K-special Tables
    codeforces 630F Selection of Personnel(组合数)
    codeforce 630N Forecast
    后缀数组模板
    Hdu5737-Differencia(有序表线段树)
  • 原文地址:https://www.cnblogs.com/zeroone/p/5864829.html
Copyright © 2020-2023  润新知