Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
170
UltraWebGrid.ExcelExport: empty Stream
posted

Server Side Code: Visual RPG

button that calls export method is within AJAX: UpdatePanel

Getting a run-time error for an empty stream.  below is the code...could some explain...I see the grid (uwItem) & it is not empty so I am not certain what the issue is.

   

BegSr

 

 

export_Click Access(*Public) Event(*This.export.Click)   

DclSrParm sender Type(*Object) 

 DclSrParm e Type(System.EventArgs)  

//Create workbook and worksheet object for Excel Workbook  

DclFld wbk Type(Infragistics.Excel.Workbook)  

DclFld wkst Type(Infragistics.Excel.WorkSheet)  

DclFld iRow Type(*Integer4 

DclFld iCell Type(*Integer4) Inz(0)  

DclFld theStream Type(System.IO.Stream)  

exp.ExportMode = Infragistics.WebUI.UltraWebGrid.ExcelExport.ExportMode.Custom

//*this.uwItem.ExportMode = Infragistics.WebUI.UltraWebGrid.ExcelExport.ExportMode.Custom

wbk.Worksheets.Add("Sheet1")

wbk.ActiveWorksheet = wbk.Worksheets["Sheet1"] 

 

//wbk = exp.Export(uwItem,theStream)

wbk = exp.Export(uwItem) <~~uwItem is the grid within the update panel

 

//Write the in memory Workbook object to the Stream

wbk.Save(theStream) 

 

If theStream <> *Nothing  

    DclFld strLen Type(*Integer4) Inz(Convert.ToInt32(theStream.Length)) <~~ Error occurs here stating that "theStream" is null

 

    DclArray byteArr Rank(1) Type(*Byte 

 

    //Create a Byte Array to contain the stream and send the exported sheet to the client

    theStream.Position=0

    theStream.Read(byteArr,0,strLen) 

 

 

    //stores data from stream onto Buffer 

 

 

 

    theStream.Close()  

    //Frees the resources used

    Response.Clear() 

 

    //Clear the buffer

    Response.AddHeader("content-disposition", "attachment; filename=ItemCrossReference.xls")

    Response.BinaryWrite(byteArr)

    Response.End()

 

 

  EndIf

 

 

EndSr

I'm At a loss

 

  • 25665
    Offline posted

    Hello,

    I followed the steps you suggested and was unable to reproduce the behavior you're describing.  I created a sample with a UltraWebGrid and UltraWebGridExcelExporter and a button inside an update panel. I set the update panel to have the button click trigger a post back and inside the button click exported the grid to an excel sheet. It performed as expected the grid was exported.

    I have attached the sample project I used to test this.  Please test this project on your PC; whether or not it works correctly may help indicate the nature of this problem.

    If the project does not work correctly, this indicates either a problem possibly specific to your environment, or a difference in the DLL versions we are using.  My test was performed using version 11.1.20111.1006 in NetAdvantage for ASP.NET 2011 Volume 1.

    If the project does show the product feature working correctly, this indicates a possible problem in the code of your application.  It will help if you can provide a small, isolated sample application that demonstrates the behavior you are seeing.

    Or, if this sample project is not an accurate demonstration of what you're trying to do, please feel free to modify it and send it back, or send a small sample project of your own if you have one.

    Please let me know if I can provide any further assistance.

    Sincerely,
    Mike P.
    Developer Support Engineer
    Infragistics, Inc.
    www.infragistics.com

    WebGridExcelExport.zip