I need to open up an xlsx file so that the user can see it.
I used the following code but was not able to display the excel file:
public ActionResult GetExcelReport()
{
string fileName = "Sheet1.xlsx";
string path = Path.Combine(@"C:\Test", fileName);
return File(path, "application/xlsx");
}
I was hoping that the retrun File(path ...
would actually open up the file for viewing.
Try to use
Microsoft.Office.Interop.Excel, and:By the way, you can also use
using System.Diagnostics;, andYou just open a file stream via using
File, it doesn’tLauncha file.