ページにデータを含むテーブルを表示し、ユーザーが[エクスポート]をクリックすると、データを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();