These are the following are my requirements.
- There is URL from SSRS Report which renders the report in EXCEL file
- We have setup for MVC application as web app and the webapi as App server.
- Since the ssrs inside the firewall the app server will connect only through Appserver. In Appserver, The report has been rendered as follows
public HttpResponseMessage GenerateLegacyReport()
{
try
{
string endTypeString = "&rs:Format=Excel";
url = url + businessSegmentFormat(businessSegment) + regionStringFormat(region) +
facilitySiteStringFormat(selectedSite) + fromDateFormat(FromDate) +
toDateFormat(ToDate) + salesPersonFormat(userName) + SortstringFormat(sortOrder) +
buildSortOrderUrl(sortByList) + groupByFormat(reportName, groupBy) + endTypeString;
//AlertMailer setalert = new AlertMailer();
//setalert.NOtifyError("Report", null, url);
if (!string.IsNullOrEmpty(url))
{
string _sessionPipelineReport = "PipelineReport" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls";
byte[] excelBytes = null;
using (WebClient webclient = new WebClient())
{
webclient.Credentials = CredentialCache.DefaultCredentials;
//Sample URL replaced with Actual SSRS URL
url = "https://online.utpb.edu/webapps/dur-browserCheck-bb_bb60/samples/sample.xlsx?CRMReports/CustomerProfileSummary&rs:Command=Render&BusinessSegment=%5BBusiness%20Segment%5D.%5BBUSINESS%20SEGMENT%20CODE%5D.%26%5BES%5D&Region=%5BRegion%5D.%5BREGION%20NAME%5D.%5BAll%5D&Facility=%5BFacility%5D.%5BFACILITY%20NAME%5D.%5BAll%5D&FromDate=%5BEARNED%20DATE%5D.%5BDATE%5D.%26%5B2015-01-26T00:00:00%5D&ToDate=%5BEARNED%20DATE%5D.%5BDATE%5D.%26%5B2016-01-26T00:00:00%5D&User=%5BSalesperson%5D.%5BUSERNAME%5D.%26%5BAPeterson%5D&SortOrder=Desc&SortBy=Revenue&rs:Format=Excel";
excelBytes = webclient.DownloadData(url);
}
//var result = new HttpResponseMessage(HttpStatusCode.OK) { Content = new ByteArrayContent(excelBytes) };
//result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/pdf");
//result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("inline")
var result = new HttpResponseMessage(HttpStatusCode.OK) { Content = new ByteArrayContent(excelBytes) };
result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/vnd.ms-excel");
result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("inline")
{
FileName = _sessionPipelineReport
};
return result;
}
return Request.CreateResponse(HttpStatusCode.Gone);
}
catch (Exception ex)
{
throw new Exception("Internal Server Error. Please try again...");
}
}
And we have start reading this from Web app and render it as
Response.Redirect("https://view.officeapps.live.com/op/embed.aspx?src=" +fileURL , false);
We are able to download the report but excel file nor rendered it int he viewer.
Please suggest us the solutions are any other better online viewer (supports MVC and HTML 5)
If we get the information with any sample solution would be more appreciated :)