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
165
Export two grids to one excel sheet
posted

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.

Parents Reply
  • 19308
    posted in reply to Srinivas

    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];

        }

Children