Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
65
How to use WebDocumentExporter Custom Exportmode?
posted

How can I do that if I want to export a WebDataGrid to a custom stream or location? It seems to me with version 10.3 there is no way to do it using WebDocumentExporter.

Parents
No Data
Reply
  • 3147
    Suggested Answer
    posted

    Hi,

    First you have to set the ExportMode to Custom:

    <ig:WebDocumentExporter ID="WebDocumentExporter1" runat="server" ExportMode="Custom">
    </ig:WebDocumentExporter>

    Then you can modify the following code to meet your requirements:

     protected void btnExportPDF_Click(object sender, EventArgs e)
     {
      Report report = new Report();
      WebDocumentExporter1.Export(WebDataGrid1, report);

      // Create whatever stream you need.
      MemoryStream stream = new MemoryStream();
      report.Publish(stream, FileFormat.PDF);

      HttpResponse response = HttpContext.Current.Response;
      response.Clear();
      response.AddHeader("content-disposition", "attachment; filename=report.pdf");
      response.ContentType = "application/pdf";
      response.Buffer = true;
      response.BinaryWrite(stream.ToArray());
      response.Flush();
      response.End();
     }

Children