2

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.

Caspar Kleijne
  • 21,552
  • 13
  • 72
  • 102
  • similar: http://stackoverflow.com/questions/560435/read-excel-file-from-a-stream –  Jul 06 '11 at 12:47
  • @0A0D thanks for the tip ;) but I don't have a stream like in that question ( the OP has a stream from an upload) So that question is quite the opposite, still very a helpful reference. – Caspar Kleijne Jul 06 '11 at 12:49
  • 1
    Hoping that something in that answer will pique your interest. –  Jul 06 '11 at 12:51

1 Answers1

1

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.

Samuel Neff
  • 73,278
  • 17
  • 138
  • 182