yuhuihu / excellibrary

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

Saving to stream always closes the stream #79

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create an Excel document
2. Call the Save function with a Stream
3. Try to use the stream (IE try to read the length).

What is the expected output? What do you see instead?
The stream is closed, which may not be useful to the programmer 

What version of the product are you using? On what operating system?
SVN Revision 49 is used.

Please provide any additional information below.
The attached patch will resolve this problem by adding a second parameter to 
the save function that specifies if the stream should be closed.

Original issue reported on code.google.com by uti...@gmail.com on 30 Dec 2010 at 10:34

Attachments:

GoogleCodeExporter commented 9 years ago
I am just looking at this library, and want to say thank you very much for 
providing this!

I saw the commit in http://code.google.com/p/excellibrary/source/detail?r=51, 
but that commit does not resolve the situation, but makes it even more strange. 
It seems, when CompoundDocument is disposed, then the Stream is closed as well.

This is the testing code that fails:
                Workbook workbook = new Workbook();
                Worksheet worksheet1 = new Worksheet("Test 1");
                MemoryStream stream = new MemoryStream();
                workbook.Save(stream);
                Assert.Greater(stream.Length, 0);

ExcelLibrary.Test.SimpleTest.WriteStream:
System.ObjectDisposedException : Cannot access a closed Stream.

Original comment by timotheu...@gmail.com on 6 Apr 2011 at 1:22

GoogleCodeExporter commented 9 years ago
Fixed by r53.

Original comment by China.LiuJunFeng on 14 Apr 2011 at 12:48