SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to create a sandboxed webpart to export data from another webpart within the webpart page to excel.

I tried using the Excel ActiveXObject in a client side script but it requires this META tag to be added -


How can I get this script to work? Alternatively are there any other solutions?

Note that it is enough if the solution works only in IE but I cannot change the security settings.

share|improve this question

The metadata mentioned is merely to specify what kind of content the stream has, it is also used when trying to download a file, by example, more here

Use it in the HEAD section of your page, as in:

<meta http-equiv="Content-Type" content="application/">
<meta http-equiv="Content-disposition": attachment; filename="file.xls">

In code however you use it as such

        "content-disposition", string.Format("attachment; filename={0}", fileName));
        HttpContext.Current.Response.ContentType = "application/ms-excel";
        HttpContext.Current.Response.Write("<head><meta http-equiv=Content-Type content=:" + '"' + "text/html; charset=utf-8" + '"' + "></head>");



Not sure about alternative just yet, i shall investigate on that direction.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.