Search code examples
c#epplus

Open/Save message using Epplus (C#)


I am trying to save using Epplus (C#),

This is how I declare the worksheet to write to:

ExcelWorksheet ws = pck.Workbook.Worksheets["myFile"];

The contents of the file are fine, but I'm having trouble with the save/open dialog box.

When I try to save, I get the following message:

enter image description here

It displays the file name and then a bunch of alphanumeric characters (these are different every time)

Does anyone know why this is happening?

Also as a side question, can the name that appears in the dialog box be changed?

Thanks in advance


Solution

  • I solved the error like this:

    string filename = Path.GetFileName(excelFilePath);   
    

    Then I changed this header:

    Response.AppendHeader("content-disposition", "attachment; filename=" + filename);
    

    Where excelFilePath is the directory to where the Excel file is located

    This correctly displays the file name in the open/save dialog box.