I want to read an xls from a server. I succeeded to download the file with the WebClient, but now I want to open it without saving the file.
var request = WebRequest.Create(location);
var response = request.GetResponse();
var stream = response.GetResponseStream();
var document = SpreadsheetDocument.Open(stream, false);
if (stream != null) stream.Close();
My code stops on the SpreadsheetDocument.Open, it gives teh following error:
Cannot operate on stream that does not support seeking.
What am I doing wrong, why can't I open the document?
You receive this error because the Open method of SpreadsheetDocument expects a seekable stream object. Your stream variable is an instance of NetworkStream and does not support seeking. You will have to copy the networkstream into a local stream (eg a MemoryStream) in order to use it in your code