afkmaster
afkmaster

Reputation: 297

open excel workbook from memorystream

I am trying to open an excel workbook from a memorystream. I have a web url of the excel file, what I do is I download the data from the url, then save it into a memorystream, but I am not sure how to open the workbook from the stream, here is how my code works so far.

WebClient wc = new WebClient();

byte[] fileArray = wc.DownloadData("url is inserted here");

MemoryStream ms = new MemoryStream(fileArray);

But from here I'm not sure how to go about reading the data from the stream to create the workbook, it doesn't seem like the spreadsheet document from http://msdn.microsoft.com/en-us/library/ff478410 works the way I want it to, any assistance or pointers would be appreciated

Upvotes: 14

Views: 30401

Answers (1)

Antonio Bakula
Antonio Bakula

Reputation: 20693

SpreadSheetDocument has an Open static method overload that takes stream as param for document source, just add to your code :

var doc = SpreadSheetDocument.Open(ms, isEditable);

Upvotes: 12

Related Questions