Search code examples
c#asp.netexcelopenxmlopenxml-sdk

Load Excel File From a file and Update Cells Values in Memory


Based on this article : Insert text into a cell in a spreadsheet document

I want to load an Excel file in memory and update some cells values and send it to client as a download attachment.

I know that there is an overload for Open method that use Stream but I don't know How I can load Excel file to it.

How I can Load Excel File From a file and Update Cells Values in Memory?


Solution

  • The article in this link explains in detail when and how an Excel workbook can be opened from a Stream: https://msdn.microsoft.com/en-us/library/office/ff478410.aspx

    Summarizing: there's a special overload of the Open method that accepts a Stream object and a Boolean (whether the Excel file can be edited or not).