【问题标题】:Print Devexpress grid from a page?从页面打印 Devexpress 网格?
【发布时间】:2011-10-28 04:55:54
【问题描述】:

我在 asp.net 上做一个项目

我使用 Devexpress gridview 9.1。

我想在单击按钮时打印 gridview only。 基本上页面中没有其他控件应该被打印出来。

我发现,这可以通过将网格传递到下一页并在那里打印来实现。 但我的要求不允许这样做。

那么是否可以通过任何方式在同一页面上单独打印gridview??

【问题讨论】:

  • 如果我理解正确,导出为 pdf/excel 是不可接受的?

标签: asp.net devexpress


【解决方案1】:

为此目的使用独立的 ASPxGridViewExporter 组件:

http://demos.devexpress.com/ASPxGridViewDemos/Exporting/Exporting.aspx

【讨论】:

    【解决方案2】:
     protected void ASPxButton1_Click(object sender, EventArgs e)
            {
                using(MemoryStream ms = new MemoryStream()){
                    PrintableComponentLink pcl = new PrintableComponentLink(new PrintingSystem());
                    pcl.Component = ASPxGridViewExporter1;
                    pcl.Margins.Left = pcl.Margins.Right = 50;
                    pcl.Landscape = true;
                    pcl.CreateDocument(false);
                    pcl.PrintingSystem.Document.AutoFitToPagesWidth = 1;
                    pcl.ExportToPdf(ms);
                    WriteResponse(this.Response, ms.ToArray(), System.Net.Mime.DispositionTypeNames.Inline.ToString());
                }
            }
            public static void WriteResponse(HttpResponse response, byte[] filearray, string type)
            {
                response.ClearContent();
                response.Buffer = true;
                response.Cache.SetCacheability(HttpCacheability.Private);
                response.ContentType = "application/pdf";
                ContentDisposition contentDisposition = new ContentDisposition();
                contentDisposition.FileName = "test.pdf";
                contentDisposition.DispositionType = type;
                response.AddHeader("Content-Disposition", contentDisposition.ToString());
                response.BinaryWrite(filearray);
                HttpContext.Current.ApplicationInstance.CompleteRequest();
                try
                {
                    response.End();
                }
                catch (System.Threading.ThreadAbortException)
                {
                }
    
            }
    

    【讨论】:

      猜你喜欢
      • 2012-04-22
      • 1970-01-01
      • 2015-09-14
      • 2015-05-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多