protected void Page_Load(object sender, EventArgs e)
        {
            cm.log.Info("Kontrolka Excell start ");
            try
            {
                using (MemoryStream ms = new MemoryStream())
                {
                    PrintableComponentLink pcl = new PrintableComponentLink(new PrintingSystem());

                    ASPxGridViewExporter export = (ASPxGridViewExporter)Session["exporter"];
                    export.Styles.Header.Wrap = DevExpress.Utils.DefaultBoolean.True;

                    export.FileName = "Kontrolka.xlsx";

                    pcl.Component = export;

                    pcl.Margins.Left = pcl.Margins.Right = 50;

                    pcl.Landscape = true;
                    pcl.CreateDocument(true);
                    pcl.PrintingSystem.Document.AutoFitToPagesWidth = 0;
                    cm.log.Info("Kontrolka Excell start exportu");

                    pcl.ExportToXlsx(ms);
                    WriteResponse(this.Response, ms.ToArray(), System.Net.Mime.DispositionTypeNames.Inline.ToString());
                }
            }
            catch (Exception ex)
            {
                cm.log.Error("kontrolka excell : " + ex.Message);
            }
        }
示例#2
0
        /// <summary>
        /// Custom export to excel
        /// </summary>
        /// <param name="grid"></param>
        /// <param name="fileName"></param>
        public void ExportDataToExcel(GridControl grid, string fileName)
        {
            PrintableComponentLink link = new PrintableComponentLink(new PrintingSystem());

            link.Component = grid;

            link.CreateMarginalHeaderArea += new CreateAreaEventHandler(Link_CreateMarginalHeeaderArea);

            link.CreateDocument();

            link.ExportToXlsx(fileName);
        }
示例#3
0
        /// <summary>
        /// Custom export to excel with page title and page details
        /// </summary>
        /// <param name="grid"></param>
        /// <param name="fileName"></param>
        /// <param name="title"></param>
        /// <param name="detail"></param>
        public void ExportDataToExcel(GridControl grid, string fileName, string title, string detail)
        {
            this.ReportPageTitle  = title;
            this.ReportPageDetail = detail;

            PrintableComponentLink link = new PrintableComponentLink(new PrintingSystem());

            link.Component = grid;

            link.CreateMarginalHeaderArea += new CreateAreaEventHandler(Link_CreateMarginalHeeaderArea);

            link.CreateDocument();

            link.ExportToXlsx(fileName);
        }