在IE中打开Excel和Word(2003格式测试通过)
时间:2011-02-14 来源:扯
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "Application/msword";
string strFilePath = "";
strFilePath = Server.MapPath("高手帮你学习LINQ.doc"); //Word路径
FileStream fs = new FileStream(strFilePath, FileMode.OpenOrCreate, FileAccess.Read);
Response.WriteFile(strFilePath, 0, fs.Length);
fs.Close();
//在浏览其中打开Excel文件
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "application/vnd.ms-excel";
Response.WriteFile(Server.MapPath("Book1.xls")); //Excel路径
Response.Flush();
Response.Close();