Excel Workbook to byte array

M

Mehul

Hello,

I am trying to upload a new excel workbook to Sharepoint and for that I need
the ability to somehow obtain a byte array out of the workbook. I can do it
if the workbook is first saved to the hard drive and then I can do something
like:

String sFilePath = "C:\\tempWhatIfModel.xls";
FileStream fs = File.OpenRead(sFilePath);
byte[] file = new byte[fs.Length];
fs.Read(file, 0, file.Length);
fs.Close();

The above approach however requires that the file exists on the C:. But, I
dont know how to do this for a new workbook.

Any help will be trememndously appreciated.

Thanks.
 

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