I am trying to open an Excel document using EPPlus reference/package. I can\'t get the Excel application to open. What code am I missing?
protected void BtnTest_
Try this in ASP NET Core to avoid win32 exception:
private void CreateWorkbook(string fileName)
{
using (var p = new ExcelPackage())
{
p.Workbook.Properties.Author = "Barry Guvenkaya";
p.Workbook.Properties.Title = "MyTitle";
p.Workbook.Worksheets.Add("MySheet");
var bin = p.GetAsByteArray();
File.WriteAllBytes(fileName, bin);
// Below code opens the excel doc
var proc = new Process();
proc.StartInfo = new ProcessStartInfo(fileName)
{
UseShellExecute = true
};
proc.Start();
}
}