我在页面上显示一个包含数据的表格,然后当用户单击导出时,我将数据放入 excel 文件中。现在我想打开这个文件,以便用户可以保存它或只是查看它。这是我的代码。它提示用户保存文件,但该文件是整个页面!这里有什么问题?
string filename = filePath.Substring(12);
System.IO.File.Copy(filePath, "C:/Work/MCTestSuiteCertificate/TS.ToDoViewer/Content/" + filename, true);
Response.Clear();
Response.ContentType = @"application\xls";
// FileInfo file = new FileInfo(Server.MapPath("~/Content/" + filename));
Response.AddHeader("Filename", filename);
Response.ContentType = "application/xls";
Response.TransmitFile("C:/Work/MCTestSuiteCertificate/TS.ToDoViewer/Content/" + filename);
//Response.WriteFile(file.FullName);
Response.Flush();