Ignite UI API Reference

ig.GridExcelExporter

ig.GridExcelExporter_image
The igGridExcelExporter allows you to export the igGrid 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>

            <script type="text/javascript" src="http://modernizr.com/downloads/modernizr-latest.js"></script>
            <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>

            <!-- 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>

            <!-- Ignite UI Loader Script -->
            <script src="js/infragistics.loader.js"></script>
          </head>
          <body>
            <table id="grid"></table>
            <script type="text/javascript">
              $.ig.loader({
                scriptPath: "js/",
                cssPath: "css/",
                resources:  "modules/infragistics.util.js," +
                            "modules/infragistics.documents.core.js," +
                            "modules/infragistics.excel.js," +
                            "modules/infragistics.gridexcelexporter.js," +
                            "igGrid"
	            });

              $.ig.loader(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.export($("#grid"));
              })
            </script>
          </body>
        </html>
    

Related Samples

Related Topics

Dependencies

jquery-1.4.4.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.xlRow to get reference to the excel of the cell.

      Code Sample

        
                  //Initialize
                  $.ig.GridExcelExporter.export($(".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 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 the igGrid cell value.
      Use args.xlRow to get reference to the excel of the cell.

      Code Sample

                  //Initialize
                    $.ig.GridExcelExporter.export($(".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 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.export($(".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.
      Use args.xlRowIndex to get the excel row index.

      Code Sample

       
                  //Initialize
                  $.ig.GridExcelExporter.export($(".selector"), {}, {
                    exportEnding: function(data) {
                      //returns the exported data
                      data;
                    }
                  });
                
    • 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.export($(".selector"), {}, {
                    exportStarting: function(data) {
                      //returns the exported data
                      data;
                    }
                  });
                
    • 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.export($(".selector"), {}, {
                    headerCellExported: function(sender, args) {
                      //returns the header text of the igGrid cell
                      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 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.export($(".selector"), {}, {
                    headerCellExporting: function(sender, args) {
                      //returns the header text of the igGrid cell
                      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.row to get reference the igGrid row.
      Use args.xlRow to get reference to excel row.
      Use args.owner to get reference to the igGrid widget.

      Code Sample

                  //Initialize
                 $.ig.GridExcelExporter.export($(".selector"), {}, {
                    rowExported: function(sender, args) {
                      //returns reference to the igGrid row.
                      args.row;
                      //returns row index.
                      args.row.index; 
                      //returns row id
                      args.row.id;
                      //returns reference to the excel row.
                      args.xlRow;
                      //retruns reference to the 
                      Use args.owner to get reference to the igGridExcelExporter class.
                      Use args.owner.grid to get reference to igGrid.
                    }
                  });
                
    • rowExporting

      Type:
      object
      Default:
      null

      Cancel="true" Callback fired when row exporting has begin.
      Function takes arguments sender and args.
      Use args.row to get reference the igGrid row.
      Use args.xlRow to get reference to excel row.
      Use args.owner to get reference to the igGrid widget.

      Code Sample

                  //Initialize
                  $.ig.GridExcelExporter.export($(".selector"), {}, {
                    rowExporting: function(sender, args) {
                      //returns reference to the igGrid row.
                      args.row;
                      //returns row index.
                      args.row.index; 
                      //returns row id
                      args.row.id;
                      //returns reference to the excel row.
                      args.xlRow;
                      //retruns reference to the 
                      Use args.owner to get reference to the igGridExcelExporter class.
                      Use args.owner.grid to get reference to igGrid.
                    }
                  });
                
    • 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.export($(".selector"), {}, {
                    success: function(data) {
                      //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 excel row index.

      Code Sample

       
                  //Initialize
                  $.ig.GridExcelExporter.export($(".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;
                      //retruns the excel row index.
                      Use args.xlRowIndex to get reference to the igGridExcelExporter class.
                    }
                  });
                
    • 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 excel row index.

      Code Sample

       
                  //Initialize
                  $.ig.GridExcelExporter.export($(".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;
                      //retruns the excel row index.
                      Use args.xlRowIndex to get reference to the igGridExcelExporter class.
                    }
                  });
                
  • export

    Type:
    object
    Default:
    ""

    Exports the provided igGrid to Excel document.
    paramType="object" Grid to be exported.
    paramType="object" Settings for exporting the grid.
    paramType="object" Callbacks for the events.

    Code Sample

      
            $.ig.GridExcelExporter.export($(".selector"));
          
  • 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.export($(".selector"), {
                    // The keys of the columns that will not be exported
                    columnsToSkip: ["column1", "column2", "column3"]
                  });
                
    • fileName

      Type:
      string
      Default:
      iggrid

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

      Code Sample

                  //Set
                  $.ig.GridExcelExporter.export($(".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.export($(".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.export($(".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.export($(".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.export($(".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.export($(".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.export($(".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.export($(".selector"), {
      					      gridFeatureOptions: {
      						      // Grid style will be exported to the excel table
      						      gridStyling: "applied"
      					      }
      				      });
      		        
    • tableStyle

      Type:
      string
      Default:
      tablestylemedium1

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

      Code Sample

                  //Set
                  $.ig.GridExcelExporter.export($(".selector"), {
                    //Setting the table style tablestylemedium1
                    gridStyling: "none",
                    tableStyle: "TableStyleMedium1",
      
                  });
                
    • worksheetName

      Type:
      string
      Default:
      sheet1

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

      Code Sample

                  //Set
                  $.ig.GridExcelExporter.export($(".selector"), {
                    //Setting the name of the worksheet
                    worksheetName: "Worksheet1",
                  });
                
  • workbook

    Type:
    object
    Default:
    ""

  • worksheet

    Type:
    object
    Default:
    ""

The current widget has no events.
  • &nbspig.GridExcelExporter

    new $.ig.GridExcelExporter( );

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

#