We are planning to buy license for Syncfusion Control but during some sample design for POC I am getting error in Downloading excel file.
I am opening a Reportviewer in ASP.NET MVC.but on export to Excel click it renders the Script body as
<body><pre style="word-wrap: break-word; white-space: pre-wrap;"></pre></body>
and No excel file is downloaded.
My Code is
View Code
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>@ViewBag.Title</title>
@using Syncfusion.MVC.EJ
@using Syncfusion.JavaScript.Models
@using Syncfusion.JavaScript
<link rel='nofollow' href="@Url.Content("~/Content/ej/web/Default-theme/ej.widgets.all.min.css")" rel="stylesheet" />
<script src="@Url.Content("~/Scripts/jquery-1.10.2.min.js")"></script>
<script src="@Url.Content("~/Scripts/jsrender.min.js")"></script>
<script src="@Url.Content("~/Scripts/jquery.easing.1.3.min.js")"></script>
<script src="@Url.Content("~/Scripts/jquery.globalize.min.js")"></script>
<script src="@Url.Content("~/Scripts/ej/ej.web.all.min.js")"></script>
<script src="@Url.Content("~/Scripts/ej/ej.unobtrusive.min.js")"></script>
</head>
<body>
@if (ViewBag.ReportPath != null)
{
<div id="rptContainer" style="height: 750px;width: 850px;min-height:404px; overflow:hidden">
@(Html.EJ().ReportViewer("reportviewer").ProcessingMode(Syncfusion.JavaScript.ReportViewerEnums.ProcessingMode.Remote)
.ReportServiceUrl(@Url.Content("~/api/ReportAPI")).Parameters(param =>
{
param.Name("TenantID").Values(new List<string> { Convert.ToString(ViewBag.TenantId) }).Add();
})
.ReportServerUrl(Convert.ToString(ViewBag.ServerUrl))
.ReportPath(Convert.ToString(ViewBag.ReportPath)))
@(Html.EJ().ScriptManager())
</div>
}
else
{
<div>
The selected Report is not available
</div>
}
@*<p class="pull-right">
<input class="btn btn-success" data-dissmiss="modal" type="button" value="CLOSE">
</p>*@
@Scripts.Render("~/bundles/bootstrapOnly")
@(Html.EJ().ScriptManager())
</body>
</html>
The Controller code is
using Syncfusion.EJ.ReportViewer;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
public class ReportAPIController : ApiController, IReportController
{
public object PostReportAction(Dictionary<string, object> jsonResult)
{
return ReportHelper.ProcessReport(jsonResult, this);
}
[System.Web.Http.ActionName("GetResource")]
[System.Web.Http.AcceptVerbs("GET")]
public object GetResource(string key, string resourcetype, bool isPrint)
{
return ReportHelper.GetResource(key, resourcetype, isPrint);
}
public void OnInitReportOptions(ReportViewerOptions reportOption)
{
}
public void OnReportLoaded(ReportViewerOptions reportOption)
{
}
}
And Other View Controller
public ActionResult ReportViewer(string reportName, ReportType reportType)
{
ViewBag.TenantId = SessionState.TenantID;
var reportInformation = ReportingServices.GetReportingInformation(reportName, reportType);
var ServerUrl = Config.GetReportServerUrl;
var ReportViewer = Config.GetReportViewerName;
if (reportInformation != null)
{
ViewBag.ReportPath = reportInformation.ReportPath;
}
return PartialView();
}
Any help would be appreciated, Thanks for getting throught the post.