tgui78 / excellibrary

Automatically exported from code.google.com/p/excellibrary
0 stars 0 forks source link

Crash at CompoundDocument.cs with exception {"Stream was not writable."} #52

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Try to open a readonly excel document
2.
3.

What is the expected output? What do you see instead?

What version of the product are you using? On what operating system?

Latest build from here

Please provide any additional information below.

When the document is readonly, or if the user does not have rights to
modify the document, the underlying stream is not writable. The below line
at compounddocument.cs crashes then.

this.Writer = new BinaryWriter(this.FileStorage, Encoding.Unicode);

Wrap it up to rectify the issue

// [SokSa]Icy: The underlying file storage is not always writable. Attempt
to create a binaryWriter fails then
this.Writer = this.FileStorage.CanWrite ? new
BinaryWriter(this.FileStorage, Encoding.Unicode) : null;

Original issue reported on code.google.com by ihsan...@gmail.com on 26 Nov 2009 at 2:24

GoogleCodeExporter commented 8 years ago
The code of  Apr 23, 2009 already is:
            this.FileStorage = stream; 
             this.Reader = new BinaryReader(this.FileStorage); 
             if (stream.CanWrite) 
             { 
                 this.Writer = new BinaryWriter(this.FileStorage, Encoding.Unicode); 
             } 
 why do you still meet this problem?

Original comment by China.LiuJunFeng on 2 Feb 2010 at 3:10