Caspar Kleijne
Caspar Kleijne

Reputation: 21864

Save workbook into a stream instead of a file

Is it possible (and how) to save an Microsoft Excel workbook into a stream instead of a file?

what I have now is:

using System.Runtime.InteropServices; // Microsoft Excel 14.0 Object Library
.......
workbook.SaveAs(Filename: fileName, FileFormat: XlFileFormat.xlWorkbookNormal);

But both documentation as intellisense give me no clue how to put this in a stream and write it with a BinaryWriter e.g. to output it via the browser.

Upvotes: 2

Views: 2241

Answers (1)

Samuel Neff
Samuel Neff

Reputation: 74909

Office Automation provides an API to control tge office UI. It does not provide a way to store a workbook to a stream. To do that you need something lower level like a binary writer (POI) or Office Open XML SDK.

Upvotes: 1

Related Questions