Question posted 2008 · +12 upvotes
How do I write an Excel workbook to a MemoryStream without first saving it to the file system?
All options within the Microsoft.Office.Interop.Excel.WorkBook save options take a filename.
Accepted answer +6 upvotes
I have done extensive work with the PIA and with storing Excel files in a document repository and streaming it out to the browser, and I have not been able to find a solution to using the PIA without first writing the contents to the file system first.
I think that you are going to have to swallow the bullet and deal with the file system as an intermediary. The good news is that you can just give the file a unique name like a guid or use some other tempfilename method (not sure if one exists in .net) and just delete the contents when you are done.
Excel VBA objects referenced (4)
Interop.Excel— Using events with Excel objectsInterop.Excel— Using Excel worksheet functions in Visual BasicMicrosoft.Office— Controlling One Microsoft Office Application from AnotherMicrosoft.Office— List the Name and Office Location of Each Manager Belonging to an Exchange Distribution List
Top excel Q&A (6)
- Shortcut to Apply a Formula to an Entire Column in Excel +335 (2011)
- How should I escape commas and speech marks in CSV files so they work in Excel? +136 (2012)
- Convert xlsx to csv in linux command line +96 (2012)
- How to create a link inside a cell using EPPlus +50 (2011)
- IF statement: how to leave cell blank if condition is false ("" does not work) +44 (2013)
- T-SQL: Export to new Excel file +44 (2012)
excel solutions on this site
.