
Untitled
By: a guest on
Jul 29th, 2012 | syntax:
None | size: 0.75 KB | hits: 15 | expires: Never
How to open excel 2007/2010 on browser by using .ashx?
<a href="test.htm" target="_blank">Export</a>
<iframe src="handler1.ashx" style="height: 421px; width: 800px" ></iframe>
void ProcessRequest(HttpContext context)
{
string filePath = "E:/test.xlsx";
string filename = Path.GetFileName(filePath);
context.Response.Clear();
context.Response.AddHeader("Content-Disposition", "inline;filename=test.xlsx");
context.Response.Charset = "";
context.Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
context.Response.WriteFile(filePath);
context.Response.Flush();
context.Response.End();
}
context.Response.Write(YourExcelData);