I have already created a ashx file to open excel 2007 on website.
Here is the code in test.aspx: (call test.htm to open a popup)
<a href="test.htm" target="_blank">Export</a>
Here is the code in test.htm: (using iframe to load the excel file)
<iframe src="handler1.ashx" style="height: 421px; width: 800px" ></iframe>
Here are the code in handle.ashx:
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();
}
but the excel file is always opened by Microsoft Excel Application. Please help me.
Thank you so much.