WebViewer.MVC. Saving report export result on the server side

Sometimes you may face a necessity to save a report on a server after its preview. This can be useful if you need, for example, to analyze changes dynamic of some values. This can be a very useful feature. So, let’s try to implement it using WebViewer.MVC SharpShooterWebViewerMVC.zip. To do this we take a standard sample from the following folder: Perpetuum Software\SharpShooter Collection\Samples\SharpShooterReports.Web\SharpShooterWebMVCSkin and modify it a little bit.

1. The first thing we need to do is to add the required export filters on the form of a service class

2. Then we add a method, which we will use when exporting, to the service class:

public void ExportToPdf()
    Document document = GetReportSlot("CustomersReport").RenderDocument();
    pdfExportFilter1.Export(document, HttpContext.Current.Server.MapPath("CustomersReport.pdf"), false);

3. Add the action method to the Home controller which will be bound to some events and perform export:

public class HomeController : Controller
    public ActionResult Export()
        ServiceClass service = new ServiceClass();
        return RedirectToAction("Reports");

4. Bind the created action to the menu element:

<div id="menucontainer">
    <ul id="menu">
        <li>@Html.ActionLink("Home", "Index", "Home")</li>
        <li>@Html.ActionLink("About", "About", "Home")</li>
        <li>@Html.ActionLink("Reports", "Reports", "Home")</li>
        <li>@Html.ActionLink("Export", "Export", "Home")</li>

Add Feedback