1) We need to Instantiate a workbook object:
WorkBook wbk = new WorkBook();
2) Set the ExportMode of the Exporter to Custom:
UltraWebGridExcelExporter1.ExportMode = Infragistics.WebUI.UltraWebGrid.ExcelExport.ExportMode.Custom;
3) Add a Worksheet to the Workbook:
wbk.Worksheets.Add("Grid One");
4) Use the Export Method of the Exporter to Export the UltraGrid to the Worksheet:
this.UltraWebGridExcelExporter1.Export(this.UltraWebGrid1, wbk);
5) Populate an Excel object in memory; the Excel object is then persisted as an output stream:
MemoryStream stream = new MemoryStream();
6) Write the workbook "wbk" into our newly created stream
wbk.Save(stream);
7) Create a Byte[ to contain the stream:
Byte[ bytearray = (Byte[)Array.CreateInstance(typeof(byte),stream.Length);
8) Read the stream into the Byte[:
stream.Read (bytearray, 0, (int)stream.Length);
9) Create a new StreamMemoryStream ms = new MemoryStream(bytearray)
http://news.infragistics.com/forums/t/8775.aspx
0 comments:
Post a Comment