Skip to content

Workbook.Load(Stream)

New Discussion
Vishal Gupta
Vishal Gupta asked on Sep 9, 2016 6:48 AM

Hi,

We are facing an issue with Workbook.Load(Stream) method. The size of byte[] is 321832. Same byte array works fine with System.IO.File.WriteAllBytes.

using (Stream stream = new MemoryStream(byteArray))
{

Workbook wb = Workbook.Load(stream); //This line is throwing error

}

Exception –

at Infragistics.Documents.Core.WorkItem.ExceptionInfo..ctor(Exception e)
at Infragistics.Documents.Core.WorkItem.Execute(WorkItemScheduler scheduler)
at Infragistics.Documents.Core.WorkItemScheduler.SynchronousImpl.Execute(WorkItem workItem)
at Infragistics.Documents.Core.WorkItemExtensions.GetResult[TResult](WorkItem`1 this)
at Infragistics.Documents.Excel.Workbook.Load(Stream stream, WorkbookLoadOptions loadOptions)
at Infragistics.UserControls.SpreadsheetControl.PreviewExcelFileFromByteArray(Byte[] byteArray)

Libraries being used are – 

Infragistics4.Documents.Core.v15.2 (15.2.20152.1000)

Infragistics4.Documents.Excel.v15.2 (15.2.20152.1000)

Please suggest the resolution.

Thanks

Vishal

Sign In to post a reply

Replies

  • 0
    Vishal Gupta
    Vishal Gupta answered on Sep 6, 2016 8:28 PM

    The exception is Object reference not set to an instance of an object.

    • 0
      Milko Venkov
      Milko Venkov answered on Sep 7, 2016 1:31 PM

      Hello Vishal,

      Following the steps you suggested I was not able to reproduce this behavior. I have created a small sample project to test this. In my sample I am trying to load MS Excel workbook the same way you do it. I have tested this both with new XLSX file format as well as with the old XLS file format. In both cases the size of the byte array is around ten times bigger than in your case. Both files load correctly and no exception is thrown.

      Attached is the sample project I have tested this with as well as the Excel files I have loaded during my tests. Please, try to run my sample at your side, and let me know if you face the same issue.

      If my sample does not work correctly at your side, most probably this shows to a difference in versions of Infragistics for Windows Forms we are using. My test was performed with version 16.1.20161.1000, so please let me know the exact specific version you are using.

      If my sample works correctly at your side, this most probably shows to an issue in your environment. If this is the case please send me the excel file you are trying to load to test it at my side.

      Looking forward to your reply.

      • 0
        Vishal Gupta
        Vishal Gupta answered on Sep 7, 2016 3:04 PM

        Hi Milko,

        Currently we are using 15.2. I tried your code with my file. It resulted in same error with xlsx file. From exception it is not very clear, what is wrong. 

        As per company policy, I can't share the excel. As this is the first time we faced this issue and works for most of the cases, I would like to understand from exception stack trace what could be the issue. I would expect a meaningful message in case there is something wrong with our excel

        So could you please suggest how below exception stack trace could be related to our data and we can try to identify and fix that at our end

        at Infragistics.Documents.Core.WorkItem.ExceptionInfo..ctor(Exception e)
        at Infragistics.Documents.Core.WorkItem.Execute(WorkItemScheduler scheduler)
        at Infragistics.Documents.Core.WorkItemScheduler.SynchronousImpl.Execute(WorkItem workItem)
        at Infragistics.Documents.Core.WorkItemExtensions.GetResult[TResult](WorkItem`1 this)
        at Infragistics.Documents.Excel.Workbook.Load(Stream stream, WorkbookLoadOptions loadOptions)
        at Infragistics.UserControls.SpreadsheetControl.PreviewExcelFileFromByteArray(Byte[] byteArray)

        Thanks

      • 0
        Milko Venkov
        Milko Venkov answered on Sep 8, 2016 7:00 AM

        Hello Vishal,

        Thank you for your feedback.

        If you are able to reproduce this issue with my sample, most probably this shows to some issue in the version of Infragistics for Windows Forms you are using, or to some issue in your environment. In this case I will not need you to send me the file, which leads to this exception. What I need is the exact number of the specific version of Infragistics you are using, so I can test against this specific version. This should be something like this 15.2.xxxxx.xxxx, where all ‘x’s stand for numbers.

        Also can you give me some additional information about your environment?
        What is the Windows version on the machine where you are facing this issue?
        Where does the stream come from? Is this a local location or some network stream?
        Are you facing this issue on local machine or on some kind of remote desktop?

        Looking forward to your reply.

      • 0
        Vishal Gupta
        Vishal Gupta answered on Sep 8, 2016 4:30 PM

        Hi Milko,

        The version of Infragistics is 15.2.20152.1000.

        Windows 7 is our windows. We generate excel in memory and create byte array from it and byte array is passed to UI (from web service) for display where stream is created from it and call Load method on Workbook. It's local Machine and reproducible for Users too.

        Thanks

      • 0
        Milko Venkov
        Milko Venkov answered on Sep 9, 2016 6:48 AM

        Hello Vishal,

        I’ve tested this with Infragistics for Windows Forms 15.2.20152.1000 and was not able to reproduce this issue. I have also tested this on Windows 7 and was able to load both XLSX and XLS files.

        Some additional questions about your scenario:

        • You said you was able to reproduce this issue while was trying to load your file. Did you try to load the files I had sent you? What the result of this is?
        • Does this issue appear only with one specific file or with all the files you are trying to load?
        • You said “We are generate excel in memory…”. Can you give me more information about this? How this file was created? Did you create the file with MS Excel or with some third party software?

        Looking forward to your reply.

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Vishal Gupta
Favorites
0
Replies
6
Created On
Sep 09, 2016
Last Post
10 years ago

Suggested Discussions

Created by

Created on

Sep 9, 2016 6:48 AM

Last activity on

Sep 9, 2016 6:48 AM