HighTechTalks DotNet Forums  

How to serialize Excel Workbook into a memory stream

Dotnet Framework (Interop) microsoft.public.dotnet.framework.interop


Discuss How to serialize Excel Workbook into a memory stream in the Dotnet Framework (Interop) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
leviw
 
Posts: n/a

Default How to serialize Excel Workbook into a memory stream - 12-18-2007 , 05:08 PM






Is there a way to save a dynamically created Excel workbook to a
Memory stream? There are no overloads in the Save method to save to a
stream. I want to create a web service that will dynamically generate
an Excel file, but do not want to use a temporary file for each call.
I cannot get the stream as it says the interface is not serializable.
Is there any way to do this? Is there a way to find out if the COM
object supports IPersistFile or anything? Thanks in advance.

Levi

Reply With Quote
  #2  
Old   
leviw
 
Posts: n/a

Default Re: How to serialize Excel Workbook into a memory stream - 12-20-2007 , 03:51 PM






On Dec 18, 6:08 pm, leviw <skankwilson... (AT) gmail (DOT) com> wrote:
Quote:
Is there a way to save a dynamically created Excel workbook to a
Memory stream? There are no overloads in the Save method to save to a
stream. I want to create a web service that will dynamically generate
an Excel file, but do not want to use a temporary file for each call.
I cannot get the stream as it says the interface is not serializable.
Is there any way to do this? Is there a way to find out if the COM
object supports IPersistFile or anything? Thanks in advance.

Levi
Well, I haven't gotten much further. I did see that it supports the
IPersistStorage interface (the workbook does). I am using C# for
this, by the way. I _should_ be able to instantiate an IStorage
interface using the IPersistStorage::InitNew method, and from there
call IPersistStorage::Save, and then use the IStorage interface to
open up a stream that I can get into a byte array, right? Has anyone
had any luck with this, or has anyone worked with COM interop like
this before? I've defined these interfaces in C#, but when I try to
call IPersist.InitNew(pStg), pStg is still set to it's initial value
of NULL. Any help/insight would be greatly appreciated.


Reply With Quote
  #3  
Old   
leviw
 
Posts: n/a

Default Re: How to serialize Excel Workbook into a memory stream - 12-20-2007 , 04:07 PM



On Dec 20, 4:51 pm, leviw <skankwilson... (AT) gmail (DOT) com> wrote:
Quote:
On Dec 18, 6:08 pm, leviw <skankwilson... (AT) gmail (DOT) com> wrote:

Is there a way to save a dynamically created Excel workbook to a
Memory stream? There are no overloads in the Save method to save to a
stream. I want to create a web service that will dynamically generate
an Excel file, but do not want to use a temporary file for each call.
I cannot get the stream as it says the interface is not serializable.
Is there any way to do this? Is there a way to find out if the COM
object supports IPersistFile or anything? Thanks in advance.

Levi

Well, I haven't gotten much further. I did see that it supports the
IPersistStorage interface (the workbook does). I am using C# for
this, by the way. I _should_ be able to instantiate an IStorage
interface using the IPersistStorage::InitNew method, and from there
call IPersistStorage::Save, and then use the IStorage interface to
open up a stream that I can get into a byte array, right? Has anyone
had any luck with this, or has anyone worked with COM interop like
this before? I've defined these interfaces in C#, but when I try to
call IPersist.InitNew(pStg), pStg is still set to it's initial value
of NULL. Any help/insight would be greatly appreciated.
Correct, when I call IPersistStorage.InitNew...I've been able to cast
the workbook as an IPersistStorage. I just can't get any further than
that.


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.