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
405
ultra win grid export to excel - export to more than one sheet in excel
posted

hi

i have win form with 3 tabs. each tab has ultra win grid.

i want to export the 3 grids from the 3 tabs to the same excel file, each grid in new sheet of excel.

how can i do this? i searched in the net and didnt find an answer.

Thanks, Michal

Parents
No Data
Reply
  • 4940
    Offline posted

    Attached is a sample containing a form that has 3 tabs & 3 grids. I placed the export code in the button click event, but I'll put the code below as well.

     

    Infragistics.Documents.Excel.Workbook workbook = new Infragistics.Documents.Excel.Workbook();
    Infragistics.Documents.Excel.Worksheet worksheet1 = workbook.Worksheets.Add("Grid 1");
    Infragistics.Documents.Excel.Worksheet worksheet2 = workbook.Worksheets.Add("Grid 2");
    Infragistics.Documents.Excel.Worksheet worksheet3 = workbook.Worksheets.Add("Grid 3");
    
    ultraGridExcelExporter1.Export(grid1, worksheet1);
    ultraGridExcelExporter1.Export(grid2, worksheet2);
    ultraGridExcelExporter1.Export(grid3, worksheet3);
    
    try
    {
        workbook.Save("output.xls");
        System.Diagnostics.Process.Start("output.xls");
    }
    catch
    {
        MessageBox.Show("Please close any open instances of Excel.",
                        "Error Opening Workbook",
                        MessageBoxButtons.OK, MessageBoxIcon.Stop);
    }
    

     

    UltraGrid_ExcelExportMulti.zip
Children
No Data