Note that there are some explanatory texts on larger screens.

plurals
  1. POOpening a client-side Excel file using EPPlus
    primarykey
    data
    text
    <p>I am the middle of writing a program which has to create an excel file on a client machine and then, after they have saved and updated it then I need to import it again and apply the changes to my database. The export bit of it works fine, however when I import from the web application I get zero worksheets in my workbook. If I run it on my development machine, i.e. the website is running on the same machine as the file is located then it works fine.</p> <p>My code is as follows:</p> <pre><code>try { Productsfile = new FileInfo(PathandFileName); } catch (Exception ex) { lblStatus.Text = string.Format("Error getting file info {0}", ex.Message); return; } lblStatus.Text += "File Opened succesfully " + Productsfile.FullName + Environment.NewLine; //Open and read file try { using (ExcelPackage datafile = new ExcelPackage(Productsfile)) { ExcelWorkbook wkb = datafile.Workbook; if (wkb != null) { lblStatus.Text += string.Format("The workbook is not null and there are {0} worksheets", wkb.Worksheets.Count) + Environment.NewLine; </code></pre> <p>I have confirmed that the code gets to the last label update, which tells me there are zero worksheets in the workbook, but importantly that the workbook itself is not null.</p> <p>When we created the export the following code was used, which transfers the data stream from server to client - I am wondering if something to reverse it is needed:</p> <pre><code>Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; Response.AddHeader("content-disposition", "attachment; filename=Products.xlsx"); Response.BinaryWrite(pck.GetAsByteArray()); Response.End(); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload