Cloud
Облачный сервис для быстрого и эффективного анализа и визуализации данных для вашего бизнеса без необходимости создания своих приложений и программирования.
StiMvcReportResponse class that implements the methods for report exporting and printing. These methods take the input of all the necessary parameters to configure exporting and printing the report.StiMvcReportResponse class contains methods to export report in any format and print report to PDF and HTML. For example, implementing it for one report in order to compare them. Add two links for each print mode and three links for various export formats:
<div class="row">
<div class="col-md-4">
<h2>Print to PDF</h2>
<p>@Html.ActionLink("Print", "PrintPdf")</p>
</div>
<div class="col-md-4">
<h2>Print to HTML</h2>
<p>@Html.ActionLink("Print", "PrintHtml")</p>
</div>
</div>
<hr />
<div class="row">
<div class="col-md-4">
<h2>Export to PDF</h2>
<p>@Html.ActionLink("Export", "ExportPdf")</p>
</div>
<div class="col-md-4">
<h2>Export to HTML</h2>
<p>@Html.ActionLink("Export", "ExportHtml")</p>
</div>
<div class="col-md-4">
<h2>Export to Excel</h2>
<p>@Html.ActionLink("Export", "ExportXls")</p>
</div>
</div>
GetReport() method was used. This method loads the report template, loads the XML data file and registers this data for loaded report:
private StiReport GetReport()
{
var reportPath = Server.MapPath("~/Content/Reports/TwoSimpleLists.mrt");
var report = new StiReport();
report.Load(reportPath);
return report;
}
PrintPdf and PrintHtml:
public ActionResult PrintPdf()
{
var report = this.GetReport();
return StiMvcReportResponse.PrintAsPdf(report);
}
public ActionResult PrintHtml()
{
var report = this.GetReport();
return StiMvcReportResponse.PrintAsHtml(report);
}
ExportPdf, ExportHtml, and ExportXls. These export formats are taken for example. Also, the methods of exporting a report (and printing) can take, as input, export settings and other necessary parameters:
public ActionResult ExportPdf()
{
var report = this.GetReport();
return StiMvcReportResponse.ResponseAsPdf(report);
}
public ActionResult ExportHtml()
{
var report = this.GetReport();
return StiMvcReportResponse.ResponseAsHtml(report);
}
public ActionResult ExportXls()
{
var report = this.GetReport();
return StiMvcReportResponse.ResponseAsXls(report);
}