Exemplo n.º 1
0
        public ActionResult GenerateExcelReport(ReportExecutionBE reportexecution)
        {
            try
            {
                LoggingHelper.LogInformation("Retrieving parameters...");
                if (reportexecution == null)
                {
                    return(new EmptyResult());
                }

                Byte[] results  = ReportServer.DownloadExcel(HttpContext, reportexecution);
                var    fileName = string.Format("{0}.xls", reportexecution.ReportName);

                if (results != null && results.Length > 0)
                {
                    Session[fileName] = results;
                    return(Json(new { success = true, fileName }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new { success = false }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (SqlException ex)
            {
                LoggingHelper.LogException("Unable to generate excel bytes from report service.", ex);
                throw;
            }
            catch (Exception ex)
            {
                LoggingHelper.LogException("Unable to generate excel bytes from report service.", ex);
                throw;
            }
        }