0

I am developing one application in asp.net MVC 5.0, for reporting purpose. I am making the use of SSRS Reporting Services. I rendered report in excel format. I make call to reporting services and rendered report in "byte[] array" .then I pass this bytes to return file for download excel file. Below is code I wrriten in action :-

  public ActionResult RendertoEXCEL(string Parameter,string reportName)
        {
            byte[] ReadRequest = null;
            JavaScriptSerializer js = new JavaScriptSerializer();
            ParameterValue[] parameters = js.Deserialize<ParameterValue[]>(Parameter);
            string RptFomrat = "EXCEL";
            SSRSReportManager rptManager = new SSRSReportManager(RServiceURL, RptUserName, RptPassword);
            ReadRequest = rptManager.RenderReport(RDirName, reportName, RptFomrat, parameters);

            return File(ReadRequest, "application/vnd.ms-excel", "Report.xls");

        }

and $.get function on button click using jquery

function GetConsExcelFomrat()
    {
        jQuery.ajaxSettings.traditional = true
        var array = @Html.Raw(Json.Encode(@ViewBag.Array as ParameterValue[]));
        var arrays=JSON.stringify(array);
        var url =  '@Url.Action("RendertoEXCEL", "Reports") ?Parameter=' + arrays + '&reportName=' + '@ViewBag.rptName';

        $.get(url, function (res)
        {

            window.location = url
        });

    }

Excel file is downloading in my browser window but when I am trying to open file It shows error that " Problems during load :-Missing File:C:\Content\CSS\Style.css" I think file cant get css effect. can anybody have solution for this.

Thanks in advance.

8
  • What version of Excel you are using ? Commented Nov 23, 2017 at 6:54
  • version is Ms Excel 2007 Commented Nov 23, 2017 at 7:02
  • Are you had a file at C:\Content\CSS\Style.css Commented Nov 23, 2017 at 7:10
  • No I dont have files at this location. Commented Nov 23, 2017 at 7:20
  • Put Some css file at C:\Content\CSS\Style.css and check once Commented Nov 23, 2017 at 7:22

2 Answers 2

1

Change url like this:- var url = '@Html.Raw(@Url.Action("RendertoEXCEL", "Reports", new { Parameter = @Html.Raw(Json.Encode(@ViewBag.Parameters as ParameterValue[])),reportName = @Html.Raw(@ViewBag.rptName) })) ';

Sign up to request clarification or add additional context in comments.

Comments

0

enter image description here

  1. Click on File in top menu.
  2. Click on More options.
  3. Click on Advanced in the side menu of the Excel options box.
  4. Under the General section locate Ignore Other Applications.
  5. Uncheck the check box beside it.
  6. Click on OK.

3 Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.