ig.GridExcelExporter

ig.GridExcelExporter_image
The igGridExcelExporter allows you to export the igGrid, igTreeGrid and igHierarchicalGrid control to Excel with different settings and features specified by the developer. The igGridExcelExporter supports the igGrid Filtering, Hiding, Paging, Sorting, Summaries, ColumnFixing and Virtualization features. It exposes a rich client-side API to work with, in order to interact with the workbook that being produced throughout the export process. The igGridExcelExporter supports Infragistics themes.

Code Sample

        <!DOCTYPE html>
        <html lang="en">
          <head>
            <meta charset="UTF-8" />
            <title>GridExcelExporter</title>
            
            <!-- Infragistics Combined CSS -->
            <link href="css/themes/infragistics/infragistics.theme.css" rel="stylesheet" type="text/css" />
            <link href="css/structure/infragistics.css" rel="stylesheet" type="text/css" />
            
            <!-- jQuery Core and jQuery UI -->
            <script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
            <script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.min.js"></script>

            <!-- Infragistics Combined Scripts -->
            <script src="js/infragistics.core.js" type="text/javascript"></script>
            <script src="js/infragistics.lob.js" type="text/javascript"></script>
            
            <!-- Required for igGridExcelExporter -->
	          <script type="text/javascript" src="/js/modules/infragistics.documents.core.js"></script>
	          <script type="text/javascript" src="/js/modules/infragistics.excel.js"></script>
	          <script type="text/javascript" src="/js/modules/infragistics.gridexcelexporter.js"></script>
            
            <!-- External files for exporting -->
            <script src="http://www.igniteui.com/js/external/FileSaver.js"></script>
            <script src="http://www.igniteui.com/js/external/Blob.js"></script>

          </head>
          <body>
            <table id="grid"></table>
            <script type="text/javascript">
              $(function () {
                $("#grid").igGrid({
                  columns: [
                    { key: "ProductID", headerText: "Product ID" },
                    { key: "Name", headerText: "Name" },
                    { key: "ProductNumber", headerText: "Product number" },
                    { key: "SafetyStockLevel", headerText: "Safety stock level" }
                  ],
                  autoGenerateColumns: false,
                  primaryKey: "ProductID",
                  dataSource: [
                    { "ProductID": 1, "Name": "Adjustable Race", "ProductNumber": "AR-5381", "SafetyStockLevel": 1000 },
                    { "ProductID": 2, "Name": "Bearing Ball", "ProductNumber": "BA-8327", "SafetyStockLevel": 1000 },
                    { "ProductID": 3, "Name": "BB Ball Bearing", "ProductNumber": "BE-2349", "SafetyStockLevel": 800 },
                    { "ProductID": 4, "Name": "Headset Ball Bearings", "ProductNumber": "BE-2908", "SafetyStockLevel": 800 },
                    { "ProductID": 316, "Name": "Blade", "ProductNumber": "BL-2036", "SafetyStockLevel": 800 },
                    { "ProductID": 317, "Name": "LL Crankarm", "ProductNumber": "CA-5965", "SafetyStockLevel": 500 },
                    { "ProductID": 318, "Name": "ML Crankarm", "ProductNumber": "CA-6738", "SafetyStockLevel": 500 },
                    { "ProductID": 319, "Name": "HL Crankarm", "ProductNumber": "CA-7457", "SafetyStockLevel": 500 },
                    { "ProductID": 320, "Name": "Chainring Bolts", "ProductNumber": "CB-2903", "SafetyStockLevel": 1000 },
                    { "ProductID": 321, "Name": "Chainring Nut", "ProductNumber": "CN-6137", "SafetyStockLevel": 1000 }
                  ],
                  width: "500px",
                });

                $.ig.GridExcelExporter.exportGrid($("#grid") {
                  fileName: "igGrid"
                });
              })
            </script>
          </body>
        </html>
    

Related Samples

Related Topics

Dependencies

jquery-1.9.1.js
jquery.ui.core.js
jquery.ui.widget.js
filesaver.js
infragistics.ui.grid.framework.js
infragistics.ui.grid.columnfixing.js
infragistics.ui.grid.filtering.js
infragistics.ui.grid.hiding.js
infragistics.ui.grid.paging.js
infragistics.ui.grid.sorting.js
infragistics.ui.grid.summaries.js
infragistics.excel.js
  • callbacks

    Type:
    object
    Default:
    {}

    Callback for the exporter events.

    • cellExported

      Type:
      object
      Default:
      null

      Callback fired when cell exporting has end.
      Function takes arguments sender and args.
      Use args.columnKey to get the igGrid column key of the cell.
      Use args.columnIndex to get the igGrid column index of the cell.
      Use args.cellValue to get the igGrid cell value.
      Use args.rowId to get key or index of row.
      Use args.xlRow to get reference to the worksheet row.
      Use args.grid to get reference to the igGrid widget.

      Code Sample

        
                  //Initialize
                  $.ig.GridExcelExporter.exportGrid($(".selector"), {}, {
                    cellExported: function(sender, args) {
                      //returns the column key of the grid cell
                      args.columnKey
                      //returns the column index of the grid cell
                      args.columnIndex
                      //returns the value of the grid cell
                      args.cellValue
                      //returns the row's key or index
                      args.rowId
                      //returns reference to the current xlRow
                      args.xlRow 
                    }
                  });
                
    • cellExporting

      Type:
      object
      Default:
      null

      Cancel="true" Callback fired when cell exporting has begin.
      Function takes arguments sender and args.
      Use args.columnKey to get the igGrid column key of the cell.
      Use args.columnIndex to get the igGrid column index of the cell.
      Use args.cellValue to get or set the igGrid cell value.
      Use args.rowId to get key or index of row.
      Use args.xlRow to get reference to the worksheet row.
      Use args.grid to get reference to the igGrid widget.

      Code Sample

                  //Initialize
                    $.ig.GridExcelExporter.exportGrid($(".selector"), {}, {
                      cellExporting: function(sender, args) {
                        //returns the column key of the grid cell
                        args.columnKey
                        //returns the column index of the grid cell
                        args.columnIndex
                        //returns the value of the grid cell
                        args.cellValue
                        //returns the row's key or index
                        args.rowId
                        //returns reference to the current xlRow
                        args.xlRow 
                      }
                    });
                
    • error

      Type:
      object
      Default:
      null

      Callback fired when exporting is failed.
      Use error to get the reference of error object.

      Code Sample

       
                  //Initialize
                  $.ig.GridExcelExporter.exportGrid($(".selector"), {}, {
                    error: function(error) {
                      //returns reference to the error object
                      error;
                    }
                  });
                
    • exportEnding

      Type:
      object
      Default:
      null

      Cancel="true" Callback fired when export is ending, but the document is not saved.
      Function takes arguments sender and args.
      Use args.grid to get reference to the igGrid widget.
      Use args.workbook to get reference to the excel workbook.
      Use args.worksheet to get reference to the excel worksheet.

      Code Sample

       
                  //Initialize
                  $.ig.GridExcelExporter.exportGrid($(".selector"), {}, {
                    exportEnding: function(sender, args) {
                      //returns reference to the grid widget
                      args.grid
                      //returns reference to the excel workbook.
                      args.workbook
                      //returns reference to the excel worksheet.
                      args.worksheet
                      //returns the igGridExcelExporter settings object
                      sender.settings
                    }
                  });
                
    • exportStarting

      Type:
      object
      Default:
      null

      Cancel="true" Callback fired when the exporting has started.
      Function takes arguments sender and args.
      Use args.grid to get reference to igGrid widget.

      Code Sample

                  //Initialize
                  $.ig.GridExcelExporter.exportGrid($(".selector"), {}, {
                    exportStarting: function(sender, args) {
                      //returns reference to the grid widget
                      args.grid
                      //returns the igGridExcelExporter settings object
                      sender.settings
                    }
                  });
                
    • headerCellExported

      Type:
      object
      Default:
      null

      Callback fired when header cell exporting has end.
      Function takes arguments sender and args.
      Use args.headerText to get the igGrid column key of the header cell.
      Use args.columnKey to get the igGrid column key of the header cell.
      Use args.columnIndex to get the igGrid column index of the header cell.

      Code Sample

                  //Initialize
                  $.ig.GridExcelExporter.exportGrid($(".selector"), {}, {
                    headerCellExported: function(sender, args) {
                      //returns the header text of the igGrid column
                      args.headerText
                      //returns the column key of the grid cell
                      args.columnKey
                      //returns the column index of the igGrid cell
                      args.columnIndex
                    }
                  });
                
    • headerCellExporting

      Type:
      object
      Default:
      null

      Cancel="true" Callback fired when header cell exporting has begin.
      Function takes arguments sender and args.
      Use args.headerText to get or set the igGrid column key of the header cell.
      Use args.columnKey to get the igGrid column key of the header cell.
      Use args.columnIndex to get the igGrid column index of the header cell.

      Code Sample

                  //Initialize
                  $.ig.GridExcelExporter.exportGrid($(".selector"), {}, {
                    headerCellExporting: function(sender, args) {
                      //returns the header text of the igGrid column
                      args.headerText
                      //returns the column key of the grid cell
                      args.columnKey
                      //returns the column index of the igGrid cell
                      args.columnIndex
                    }
                  });
                
    • rowExported

      Type:
      object
      Default:
      null

      Cancel="true" Callback fired when row exporting has ended.
      Function takes arguments sender and args.
      Use args.rowId to get key or index of row.
      Use args.element to get row TR element.
      Use args.xlRow to get reference to the worksheet row.
      Use args.grid to get reference to the igGrid widget.
      Note: When exporting an igHierarchicalGrid this callback is available only for the root grid rows.

      Code Sample

                  //Initialize
                 $.ig.GridExcelExporter.exportGrid($(".selector"), {}, {
                    rowExported: function(sender, args) {
                      //returns igGrid row key or id.
                      args.rowId;
                      //returns the row <tr> element.
                      args.element; 
                      //returns reference to the worksheet row.
                      args.xlRow;
                      //retruns reference to the 
                      Use args.grid to get reference to the grid widget.
                      args.grid
                    }
                  });
                
    • rowExporting

      Type:
      object
      Default:
      null

      Cancel="true" Callback fired when row exporting has begin.
      Function takes arguments sender and args.
      Use args.rowId to get key or index of row.
      Use args.element to get row TR element.
      Use args.xlRow to get reference to the worksheet row.
      Use args.grid to get reference to the igGrid widget.
      Note: When exporting an igHierarchicalGrid this callback is available only for the root grid rows.

      Code Sample

                  //Initialize
                  $.ig.GridExcelExporter.exportGrid($(".selector"), {}, {
                    rowExporting: function(sender, args) {
                      //returns igGrid row key or id.
                      args.rowId;
                      //returns the row <tr> element.
                      args.element; 
                      //returns reference to the worksheet row.
                      args.xlRow;
                      // returns reference to the grid widget.
                      args.grid
                    }
                  });
                
    • success

      Type:
      object
      Default:
      null

      Callback fired when exporting is successful.
      Use data to get the reference of saved object.

      Code Sample

                  //Initialize
                  $.ig.GridExcelExporter.exportGrid($(".selector"), {}, {
                    success: function(sender, data) {
                      //returns a reference to the igGridExporter class
                      sender
                      //returns exported data
                      data
                    }
                  });
                
    • summaryExported

      Type:
      object
      Default:
      null

      Callback fired when cell exporting has end.
      Function takes arguments sender and args.
      Use args.headerText to get the igGrid column header text.
      Use args.columnKey to get the igGrid column key.
      Use args.columnIndex to get the igGrid column index.
      Use args.summary to get a reference to the summary object.
      Use args.xlRowIndex to get the worksheet row index.

      Code Sample

       
                  //Initialize
                  $.ig.GridExcelExporter.exportGrid($(".selector"), {}, {
                    summaryExported: function(sender, args) {
                      //returns reference to the igGrid column header text.
                      args.headerText;
                      //returns reference to the igGrid column key.
                      args.columnKey;
                      //returns the the igGrid column index.
                      args.columnIndex;
                      //returns a reference to the summary object.
                      args.summary;
                      //returns a reference to the summary row index.
                      args.summaryRowIndex;
                      //returns the excel row index.
                      args.xlRowIndex
                    }
                  });
                
    • summaryExporting

      Type:
      object
      Default:
      null

      Cancel="true" Callback fired when summary exporting has begun.
      Function takes arguments sender and args.
      Use args.headerText to get the igGrid column header text.
      Use args.columnKey to get the igGrid column key.
      Use args.columnIndex to get the igGrid column index.
      Use args.summary to get a reference to the summary object.
      Use args.xlRowIndex to get reference to worksheet row index.

      Code Sample

       
                  //Initialize
                  $.ig.GridExcelExporter.exportGrid($(".selector"), {}, {
                    summaryExporting: function(sender, args) {
                      //returns reference to the igGrid column header text.
                      args.headerText;
                      //returns reference to the igGrid column key.
                      args.columnKey;
                      //returns the the igGrid column index.
                      args.columnIndex;
                      //returns a reference to the summary object.
                      args.summary;
                      //returns a reference to the summary row index.
                      args.summaryRowIndex;
                      //returns the excel row index.
                      args.xlRowIndex
                    }
                  });
                
  • settings

    Type:
    object
    Default:
    {}

    The Infragistics Grid Excel exporter client-side component is implemented as a class, and exports the igGrid control with the columnfixing, filtering, hiding, paging, sorting, and summaries features.

    • columnsToSkip

      Type:
      array
      Default:
      []
      Elements Type:
      object

      List of strings containing the keys for the columns that will not be exported.

      Code Sample

                  //Set
                  $.ig.GridExcelExporter.exportGrid($(".selector"), {
                    // The keys of the columns that will not be exported
                    columnsToSkip: ["column1", "column2", "column3"]
                  });
                
    • dataExportMode

      Type:
      enumeration
      Default:
      allRows

      Indicates whether all sublevel data will be exported, or only data under expanded rows.

      Members

      • allRows
      • Type:string
      • All sublevel data will be exported.
      • expandedRows
      • Type:string
      • Only data under expanded rows will be exported.

      Code Sample

                  //Set
                  $.ig.GridExcelExporter.exportGrid($(".selector"), {
                    //Setting the dataExportMode option
                    dataExportMode: "expandedRows",
                  });
                
    • fileName

      Type:
      string
      Default:
      "document"

      Specifies the name of the excel file that will be generated.

      Code Sample

                  //Set
                  $.ig.GridExcelExporter.exportGrid($(".selector"), {
                    //Setting the file name
                    fileName: "Document",
                  });
                
    • gridFeatureOptions

      Type:
      object
      Default:
      {}

      List of export settings which can be used with Grid Excel exporter.

      • columnfixing

        Type:
        enumeration
        Default:
        none

        Indicates whether fixed columns will be applied in the exported table. This is set to none by default, but will change to applied if column fixing feature is defined in the igGrid.

        Members

        • none
        • Type:string
        • No column fixing will be applied in the excel document.
        • applied
        • Type:string
        • Column fixing will be applied in the excel document.

        Code Sample

         
        				        //Set
        				        $.ig.GridExcelExporter.exportGrid($(".selector"), {
        					        gridFeatureOptions: {
        						        // Exports without columnFixing enabled in the excel document
        						        columnFixing: "none"
        					        }
        				        });
        			      
      • filtering

        Type:
        enumeration
        Default:
        none

        Indicates whether filtering will be applied in the exported table. this is set to none by default, but will change to applied if filtering feature is defined in the igGrid.

        Members

        • none
        • Type:string
        • No filtering will be applied in the excel document.
        • applied
        • Type:string
        • Filtering will be applied in the excel document.
        • filteredRowsOnly
        • Type:string
        • Filtering will be exported in the excel document.

        Code Sample

        				        //Set
        				        $.ig.GridExcelExporter.exportGrid($(".selector"), {
        					        gridFeatureOptions: {
        						        // Exports without filtering enabled in the excel document
        						        filtering: "none"
        					        }
        				        });
        			          
      • hiding

        Type:
        enumeration
        Default:
        none

        Indicates whether hidden columns will be removed from the exported table. This is set to none by default, but will change to applied if hiding feature is defined in the igGrid.

        Members

        • none
        • Type:string
        • All hidden columns will be exported to the excel document.
        • applied
        • Type:string
        • Hidden columns will be exported as hidden in the excel document.
        • visibleColumnsOnly
        • Type:string
        • Only visible columns will be exported.

        Code Sample

         
        				        //Set
        				        $.ig.GridExcelExporter.exportGrid($(".selector"), {
        					        gridFeatureOptions: {
        						        // No columns will be hidden in the excel document
        						        hiding: "none"
        					        }
        				        });
        			          
      • paging

        Type:
        enumeration
        Default:
        allRows

        Indicates whether the rows on the current page or entire data will exported.

        Members

        • currentPage
        • Type:string
        • Only current page will be exported to the excel document.
        • allRows
        • Type:string
        • All pages will be exported to the excel document.

        Code Sample

         
        				        //Set
        				        $.ig.GridExcelExporter.exportGrid($(".selector"), {
        					        gridFeatureOptions: {
        						        // Exports the currentPage in the excel document
        						        paging: "currentPage"
        					        }
        				        });
        			          
      • sorting

        Type:
        enumeration
        Default:
        none

        Indicates whether sorting will be applied in the exported table. This is set_ to none by default, but will change to applied if sorting feature is defined in the igGrid.

        Members

        • none
        • Type:string
        • No sorting will be applied in the excel document.
        • applied
        • Type:string
        • Sorting will be applied in the excel document.

        Code Sample

         
        				        //Set
        				        $.ig.GridExcelExporter.exportGrid($(".selector"), {
        					        gridFeatureOptions: {
        						        // No sorting will be applied to the excel document
        						        sorting: "none"
        					        }
        				        });
        			          
      • summaries

        Type:
        enumeration
        Default:
        none

        Indicates whether summaries will be added in the exported table. This is set to none by default, but will change to applied if summaries feature is defined in the igGrid.

        Members

        • none
        • Type:string
        • No summaries will be exported to the excel document.
        • applied
        • Type:string
        • Summaries will be exported to the excel document.

        Code Sample

        				        //Set
        				        $.ig.GridExcelExporter.exportGrid($(".selector"), {
        					        gridFeatureOptions: {
        						        // No summaries will be applied to the excel document
        						        summaries: "none"
        					        }
        				        });
        			          
    • gridStyling

      Type:
      enumeration
      Default:
      applied

      Indicates whether excel table styles will be the same as grid styles. This is set to applied by default. Custom grid themes are not supported.

      Members

      • none
      • Type:string
      • The styles from the grid are not applied to the table region.
      • applied
      • Type:string
      • The styles from the grid are applied to the table region.

      Code Sample

       
      				      //Set
      				      $.ig.GridExcelExporter.exportGrid($(".selector"), {
      						      // Grid style will be exported to the excel table
      						      gridStyling: "applied"
      				      });
      		        
    • skipFilteringOn

      Type:
      array
      Default:
      []
      Elements Type:
      object

      List of strings containing the keys for the worksheet columns which will not be applied any filtering.

      Code Sample

                  //Set
                  $.ig.GridExcelExporter.exportGrid($(".selector"), {
                      // The keys of columns that filtering will skip
                      skipFilteringOn: ["column1", "column2", "column3"],
                   });
                
    • tableStyle

      Type:
      string
      Default:
      "TableStyleMedium1"

      Specifies the excel table style region.
      You can set the following table style
      TableStyleMedium[1-28]
      TableStyleLight[1-21]
      TableStyleDark[1-11].

      Code Sample

                  //Set
                  $.ig.GridExcelExporter.exportGrid($(".selector"), {
                      gridStyling: "none",
                      //Setting the table style to TableStyleDark
                      tableStyle: "TableStyleDark2" 
                   });
                
    • worksheetName

      Type:
      string
      Default:
      "Sheet1"

      Specifies the name of workbook where the igGrid will be exported.

      Code Sample

                  //Set
                  $.ig.GridExcelExporter.exportGrid($(".selector"), {
                    //Setting the name of the worksheet
                    worksheetName: "Worksheet1",
                  });
                
The current widget has no events.
  • ig.GridExcelExporter
    Constructor

    new $.ig.GridExcelExporter( );

  • exportGrid

    .exportGrid( grid:object, userSettings:object, userCallbacks:object );

    Exports the provided igGrid to Excel document.

    • grid
    • Type:object
    • Grid to be exported.
    • userSettings
    • Type:object
    • Settings for exporting the grid.
    • userCallbacks
    • Type:object
    • Callbacks for the events.

    Code Sample

     
            //Set
            var exp = new $.ig.GridExcelExporter();
            exp.exportGrid($(".selector"), {
              fileName: "igGrid",
              gridFeatureOptions: {"sorting": "applied", "filtering": "applied", "paging": "currentPage"}
            });
          

Copyright © 1996 - 2024 Infragistics, Inc. All rights reserved.