How to Write Worksheet to MemoryStream in .NET 2.0

B

Bren

I am developing a windows forms application in .NET 2.0 using VS2005.

One of my forms has a grid that I want to convert to Excel and attach
to an email and send using System.Net.Mail.

..NET 2.0 has a MemoryStream class that can be attached to an email.

mail.Attachments.Add(New Attachment(attachmentStream1, "ExcelFile.xls",
"excel/xlsss"))

Using Excel Automation, I have created a Workbook. I can save the
workbook to disk, but I want to write it to the MemoryStream object to
use as the attachmentStream. The app is looping through a list of
recipients, using a MemoryStream would be faster than writing then reading
the file to and from disk.

How can I get the Worksheet into a MemoryStream?
 
C

Cindy M.

Hi =?Utf-8?B?QnJlbg==?=,

I believe the response with suggested approaches given to you in the is the
only answer: Excel does not support transfering its file content directly
into a Memory Stream.
I am developing a windows forms application in .NET 2.0 using VS2005.

One of my forms has a grid that I want to convert to Excel and attach
to an email and send using System.Net.Mail.

..NET 2.0 has a MemoryStream class that can be attached to an email.

mail.Attachments.Add(New Attachment(attachmentStream1, "ExcelFile.xls",
"excel/xlsss"))

Using Excel Automation, I have created a Workbook. I can save the
workbook to disk, but I want to write it to the MemoryStream object to
use as the attachmentStream. The app is looping through a list of
recipients, using a MemoryStream would be faster than writing then reading
the file to and from disk.

How can I get the Worksheet into a MemoryStream?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top