2011-10-28 7 views
0

나는 asp.net에서 프로젝트를하고있다페이지에서 Devexpress 그리드를 인쇄 하시겠습니까?

나는 Devexpress gridview 9.1을 사용한다.

버튼 클릭으로에만 gridview 만 인쇄하고 싶습니다. 기본적으로 페이지에 다른 컨트롤이 인쇄되어 있지 않아야합니다.

나는 다음 페이지에 그리드를 전달하여 인쇄 할 수 있음을 발견했다. 하지만 내 요구 사항은 허용하지 않습니다.

그럼 어떤 방법으로도 같은 페이지에 그리드보기를 단독으로 인쇄 할 수 있습니까 ??

+0

내가 제대로 PDF로 수출을 이해하는 경우는 허용되지 않습니다? – Filip

답변

0
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) 
      { 
      } 

     } 
관련 문제