GoogleCodeArchive / excellibrary

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

ExcelLibrary.SpreadSheet.Workbook.Load(template) = Exception "Stream was not writable" #69

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create and save normal xls file as template.xls
2. book = ExcelLibrary.SpreadSheet.Workbook.Load("template.xls")
3.

What is the expected output? What do you see instead?
Expect xls file to loadin memory / book object

What version of the product are you using? On what operating system?
ExcelLibrary_20090331, XP SP3, VS2008

Please provide any additional information below.
ASP.NET project (VB.NET)
Files saved as xls or xl97 format, with / without macro - same concern.

Exception...
"Stream was not writable."

Stack...
   at System.IO.BinaryWriter..ctor(Stream output, Encoding encoding)
   at ExcelLibrary.CompoundDocumentFormat.CompoundDocument..ctor(Stream stream, FileHeader header)
   at ExcelLibrary.CompoundDocumentFormat.CompoundDocument.Open(Stream stream)
   at ExcelLibrary.CompoundDocumentFormat.CompoundDocument.Read(Stream stream)
   at ExcelLibrary.SpreadSheet.Workbook.Load(Stream fileStream)
   at ExcelLibrary.SpreadSheet.Workbook.Load(String file)
   at PPMSWEB.ExcelLibraryReportBuilder.ReadTemplate(String template)
   at PPMSWEB.ProductionOverview.ExportButton_Click(Object sender, EventArgs e)
   at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
   at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
   at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
   at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
   at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Original issue reported on code.google.com by sdmclaug...@gmail.com on 24 Sep 2010 at 3:16

GoogleCodeExporter commented 9 years ago
I had the same problem a few days ago, and I solved altering a piece of code in 
the  Office\Excel\SpreadSheet\Workbook.cs

     public static Workbook Load(string file)
        {
                        // I Changed the following piece of code because of error "stream not writable"
            //return Load(File.OpenRead(file));
            return Load(File.Open(file, FileMode.OpenOrCreate));
        }

Original comment by ElBer...@gmail.com on 4 Oct 2010 at 12:41