Hi
I'm facing a problem that I have to export the data from two ultra web grids to one single excel sheet in a workbook.
can anybody help me in solving this.
Regards.
Hi Tony
your sample code is good, it exports the data into two worksheets in a workbook.
But I don't want that. I want two webgrid's data to be exported to only one worksheet of a workbook. means two grids are in one worksheet.
here is the version details of Infragistics I'm using
<add assembly="Infragistics2.WebUI.WebResizingExtender.v8.1, Version=8.1.20081.2013,
Hope u understood.
Thanks & Regards
If you take a look at the samples included with NetAdvantage, you'll see under WebGrid -> Spreadsheet support there's a sample that exports 2 grids into two separate worksheets in a single excel file. This should be a good place for you to get started.
Here's the important code -
protected void ExportToExcel(object sender, EventArgs e) { Infragistics.Excel.Workbook workbook = new Infragistics.Excel.Workbook(); workbook.Worksheets.Add("Sheet1"); workbook.Worksheets.Add("Sheet2"); this.CopyPasteGrid1.DisplayLayout.ColHeadersVisibleDefault = ShowMarginInfo.No; this.UltraWebGridExcelExporter1.Export(this.CopyPasteGrid1, workbook); for (int i = 0; i < this.CopyPasteGrid1.Columns.Count; i++) { workbook.Worksheets[0].Columns[i].Width = 2000; } this.CopyPasteGrid2.DisplayLayout.ColHeadersVisibleDefault = ShowMarginInfo.No; workbook.ActiveWorksheet = workbook.Worksheets[1]; this.UltraWebGridExcelExporter1.Export(this.CopyPasteGrid2, workbook); for (int i = 0; i < this.CopyPasteGrid2.Columns.Count; i++) { workbook.Worksheets[1].Columns[i].Width = 2000; } workbook.ActiveWorksheet = workbook.Worksheets[0]; }
There are a bunch of overrides on the Export method. The one you'll want to use in particular is Export(grid, worksheet, startrow, startcolumn)
In order to use this method, you'll want to create a new workbook, which can be done by leveraging the Infragistics.Excel library.
Hope this helps,
-Tony