如何在Windows应用程序中打开c#中的excel文件

问题描述:

如何在Windows应用程序中的c#中打开excel文件

how to open a excel file in c# in windows application

请尝试使用 GOOGLE [ ^ ]



http://www.dotnetperls.com/excel [ ^ ]

http ://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.workbooks.open.aspx [ ^ ]

http://msdn.microsoft.com/en-us/library/ms173186(v=vs.80).aspx [ ^ ]

使用C#进行Excel导航和导航 [ ^ ]
Please try to use GOOGLE[^]

http://www.dotnetperls.com/excel[^]
http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.workbooks.open.aspx[^]
http://msdn.microsoft.com/en-us/library/ms173186(v=vs.80).aspx[^]
Opening and Navigating Excel with C#[^]


string excelFilePath =YourExcelFilePath;

System.IO.FileInfo file = new System.IO.FileInfo(excelFilePath);



if(file.Exists)

{

Response.Clear();

Response.AddHeader(Content-Disposition,附件; filename =+ file.Name);

Response.AddHeader(Content-Length,file.Length.ToString());

Response.ContentType =application / octet-stream;

Response.WriteFile(file.FullName);

Response.End();

}
string excelFilePath = "YourExcelFilePath";
System.IO.FileInfo file = new System.IO.FileInfo(excelFilePath);

if (file.Exists)
{
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);
Response.AddHeader("Content-Length", file.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.WriteFile(file.FullName);
Response.End();
}