Click here to Skip to main content
15,898,968 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I have a link that generates a SharePoint Modal Dialog which results in an EXCEL spreadsheet. It works fine except when I close the EXCEL document, the document unloads but the parent page stays in Modal Mode. Is there any way to solve this? Below is the Java Script from the parent page.

C#
function OpenAdvertisedDialog() {
          var dialogOptions = {
              url: "/_layouts/apply/reports/advertised_billets.aspx",
              autoSize: true,
              allowMaximize: false,
              dialogReturnValueCallback: onCloseCallback
          };
          SP.UI.ModalDialog.showModalDialog(dialogOptions)
      }


      function onCloseCallback(dialogResult, returnValue) {
          SP.UI.ModalDialog.RefreshPage(SP.UI.DialogResult.OK);
      }

Here is code behind creating XLS

  private void ExportToExcel()
        {
            //Export the GridView to Excel

            PrepareGridViewForExport(gvReport);
            string style = @"<style> .text { mso-number-format:\@; } </style> ";

            string attachment = "attachment; filename=Advertised Billets Report.xls";

            Response.ClearContent();

            Response.AddHeader("content-disposition", attachment);

            Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";

            StringWriter sw = new StringWriter();

            HtmlTextWriter htw = new HtmlTextWriter(sw);

            gvReport.RenderControl(htw);

            Response.Write(style);
            Response.Write(sw.ToString());

            Response.End();
        }
Posted
Updated 2-Mar-13 4:44am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900