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 is in HTML <meta> http-equiv Attribute.
Use it in the HEAD section of your page, as in:
<head>
<meta http-equiv="Content-Type" content="application/vnd.ms-excel">
<meta http-equiv="Content-disposition": attachment; filename="file.xls">
</head>
In code, however, you use it as such:
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.AddHeader(
"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>");
// BUILD YOUR STRING HERE
HttpContext.Current.Response.Write(sw.ToString());
HttpContext.Current.Response.End();
I am not sure about an alternative just yet. I shall investigate in that direction.