none
Excel Macro's code not working through IIS RRS feed

  • Question

  • Hi Team,

                  

    I am trying to execute the below code in button click . The code is working fine in local and debugging .but not working in the IIS. please Help .

     protected void btnsubmit_Click(object sender, EventArgs e)
        {

            //~~> Define your Excel Objects
            Excel.Application xlApp = new Excel.Application();



            Excel.Workbook workbook = xlApp.Workbooks.Add(true);

            string generator = Server.MapPath("~/Generator/Test_1.xlsm");
            //string filename = Path.GetFileName(flp.FileName);
            //string filepath = Server.MapPath("~/source/");
            //flp.PostedFile.SaveAs(filepath + filename);

            //string source = Server.MapPath("~/source/") + filename;

            //string destination=Server.MapPath("~/Template/837P.xls");

            //~~> Start Excel and open the workbook.
            workbook = xlApp.Workbooks.Open(generator);

            //~~> Run the macros by supplying the necessary arguments
            try
            {
               xlApp.Run("Test_1.xlsm!ShowMsg");
            }        
            catch (Exception ex)
            {

                Response.Write("error:"+ex.Message);
            }
            //xlApp.Run("Btnexecute_Click", source, destination);

           // RunMacro(xlApp, new Object[] { "Test_1.xlsm!ShowMsg" });

            //~~> Clean-up: Close the workbook
            workbook.Close(false);


            //~~> Quit the Excel Application
            xlApp.Quit();

            //~~> Clean Up
            releaseObject(xlApp);
            releaseObject(workbook);

           Response.Redirect("~/Template/837P.xls");
        }

    Thanks Naveen


    Naveen

    • Moved by Anna Cc Monday, December 1, 2014 6:14 AM
    Sunday, November 30, 2014 7:50 AM

Answers

  • Hi Naveen,

    Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.

    You can get more detail from link below:
    Considerations for server-side Automation of Office

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, December 1, 2014 8:56 AM
    Moderator

All replies

  • As your issue is about IIS and not about .NET Framework setup (this forum's topic), I suggest you ask in a topical IIS forum, here:

    http://forums.iis.net/

    Sunday, November 30, 2014 2:12 PM
  • Hi Naveen,

    I think it is better to ask this issue in Excel for developers forum. So I will move it there. Thank you for your understanding!

    Best regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, December 1, 2014 6:13 AM
  • Hi Naveen,

    Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.

    You can get more detail from link below:
    Considerations for server-side Automation of Office

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, December 1, 2014 8:56 AM
    Moderator