/*!@license
 * Infragistics.Web.ClientUI Widget 15.2.20152.1027
 *
 * Copyright (c) 2011-2015 Infragistics Inc.
 *
 * http://www.infragistics.com/
 *
 * 
 * Depends on:
 *  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
 */
if(typeof jQuery!=="function"){throw new Error("jQuery is undefined")}(function($){$.ig=$.ig||{};$.ig.GridExcelExporter=$.ig.GridExcelExporter||Class.extend({settings:{fileName:"document",gridFeatureOptions:{sorting:"none",paging:"allRows",hiding:"none",filtering:"none",columnfixing:"none",summaries:"none"},worksheetName:"Sheet1",columnsToSkip:[],tableStyle:"TableStyleMedium1",gridStyling:"applied",dataExportMode:"allRows"},callbacks:{exportStarting:null,cellExporting:null,cellExported:null,headerCellExporting:null,headerCellExported:null,rowExporting:null,rowExported:null,summaryExporting:null,summaryExported:null,exportEnding:null,success:null,error:null},init:function(){this.settings=$.extend({},this.settings);this.callbacks=$.extend({},this.callbacks)},exportGrid:function(grid,userSettings,userCallbacks){this._setGridReferences(grid);this._setSettings(userSettings);this._setCallbacks(userCallbacks);if(!this._handleEventCallback(this.callbacks.exportStarting,{grid:this._gridWidget})){return}var self=this;setTimeout(function(){self._createExcelWorkbookWithWorksheet();if(self._columnsToExport.length>0){self._getGridStyles();self._exportHeaders();self._setDataToExport();self._createExcelTableRegion();self._exportDataSegment();if(self._shouldResizeTableRegion){self._resizeTableRegion()}self._exportFeatures();self._calculateColumnsSize();self._styleChildGridHeaders()}var noCancel=self._handleEventCallback(self.callbacks.exportEnding,{grid:self._gridWidget,workbook:self._workbook,worksheet:self._worksheet});if(!noCancel){return}self._saveWorkbook()},0)},_setGridReferences:function(grid){if(grid.data().igHierarchicalGrid!==undefined){this._gridType="igHierarchicalGrid";this._grid=grid.data()[this._gridType];this._gridData=this._grid.options.dataSource;if(this._grid.options.columnLayouts[0].responseDataKey!==undefined){this._gridData=this._grid.options.dataSource[this._grid.options.columnLayouts[0].responseDataKey]}this._dataRows=grid.data("igGrid").rows().siblings("[role='row']")}else{if(grid.data().igTreeGrid!==undefined){this._gridType="igTreeGrid"}else{this._gridType="igGrid"}this._grid=grid.data()[this._gridType];this._gridData=this._grid.dataSource.data();this._dataRows=this._grid.rows().siblings("[role='row']")}this._gridWidget=grid;this._allColumnLayoutsKeys=[]},_setSettings:function(userSettings){this._enableFeaturesAsInGrid();this._setUserSettings(userSettings);this._setColumnsToExport(this.settings.columnsToSkip);if(this._grid.options.columnLayouts!==undefined){this._getAllColumnLayoutKeys(this._grid.options.columnLayouts[0])}},_enableFeaturesAsInGrid:function(){for(var gridFeatureOption in this.settings.gridFeatureOptions){if(!this._getFeature(gridFeatureOption)){continue}if(gridFeatureOption==="paging"){this.settings.gridFeatureOptions[gridFeatureOption]="allRows"}else{this.settings.gridFeatureOptions[gridFeatureOption]="applied"}}},_setUserSettings:function(userSettings){this.settings=$.extend(this.settings,userSettings)},_setColumnsToExport:function(){var gridColumns=this._grid.options.columns,columnsToSkip=this.settings.columnsToSkip;this._columnsToExport=[];if(gridColumns.length===0&&this._gridType==="igHierarchicalGrid"){gridColumns=this._grid.rootWidget().options.columns}for(var i=0;i<gridColumns.length;i++){var gridColumn=gridColumns[i];if(gridColumn.hidden&&this.settings.gridFeatureOptions.hiding==="visibleColumnsOnly"){continue}if(columnsToSkip.indexOf(gridColumn.key)<0){this._columnsToExport.push(gridColumn)}}},_setCallbacks:function(userCallbacks){this.callbacks=$.extend(this.callbacks,userCallbacks)},_createExcelWorkbookWithWorksheet:function(){this._xlRowIndex=0;this._workbook=new $.ig.excel.Workbook($.ig.excel.WorkbookFormat.excel2007);this._worksheet=this._workbook.worksheets().add(this.settings.worksheetName)},_getGridStyles:function(){var gridTable=this._gridWidget,headersTable=this._gridWidget.find("thead").length>0?this._gridWidget.find("thead"):this._grid.headersTable().find("thead");if(gridTable.length===0){gridTable=this._gridWidget}if(this.settings.gridStyling==="applied"){var $stylesTR=$("<tr>").attr({"class":"ui-ig-altrecord ui-iggrid-altrecord"}).appendTo(headersTable).css("display","none");var $th=$(headersTable.find("tr[data-header-row]").find("th")[0]).clone().css("display","none");$stylesTR.append($th);this._headersBackColor=$th.removeClass("ui-state-active").css("background-color");$th.remove();this._headersForeColor=headersTable.find(".ui-iggrid-headertext").css("color");if($stylesTR.css("background-color").indexOf("rgba")>-1){var backTopColor=$stylesTR.css("background-color").replace("rgba(","").replace(")","").split(", ");var backBotColor=gridTable.css("background-color").replace("rgb(","").replace(")","").split(", ");this._altRowColor=this._RGBAtoRGB(backTopColor[0],backTopColor[1],backTopColor[2],backTopColor[3],backBotColor[0],backBotColor[1],backBotColor[2])}else{this._altRowColor=$stylesTR.css("background-color")}this._notAltRowColor=gridTable.css("background-color");this._rowForeColor=gridTable.css("color");$stylesTR.remove();this._getCellFill()}},_RGBAtoRGB:function(r,g,b,a,r2,g2,b2){var r3=a*r+(1-a)*r2;var g3=a*g+(1-a)*g2;var b3=a*b+(1-a)*b2;return"rgb("+r3+","+g3+","+b3+")"},_setDataToExport:function(){var paging=this.settings.gridFeatureOptions.paging,filtering=this.settings.gridFeatureOptions.filtering;this._dataToExport=[];if(paging==="currentPage"&&this._getFeature("Paging")){this._dataToExport=this._grid.dataSource.dataView()}else if(filtering!=="filteredRowsOnly"){this._dataToExport=this._gridData}else{this._dataToExport=this._grid.dataSource._filteredData;if(this._dataToExport===undefined){this._dataToExport=this._gridData}}},_createExcelTableRegion:function(){var regionRowsLength,counter=0;regionRowsLength=this._dataToExport.length;for(var i=0;i<this._columnsToExport.length;i++){if(this._columnsToExport[i].hidden){counter++}}this._worksheetRegion=new $.ig.excel.WorksheetRegion(this._worksheet,0,0,regionRowsLength,this._columnsToExport.length-1);this._worksheetTable=this._worksheetRegion.formatAsTable(true);this._worksheetTable.style(this._workbook.standardTableStyles(this.settings.tableStyle));this._woorksheetTableColumns=this._worksheetTable.columns()},_exportHeaders:function(){var gridColumn,xlRow=this._worksheet.rows(this._xlRowIndex);this._headerFill=$.ig.excel.CellFill.createSolidFill(this._headersBackColor);xlRow.cellFormat().font().bold(1);for(var columnIndex=0;columnIndex<this._columnsToExport.length;columnIndex++){gridColumn=this._columnsToExport[columnIndex];var args={headerText:gridColumn.headerText,columnKey:gridColumn.key,columnIndex:columnIndex,xlRow:xlRow},noCancel=this._handleEventCallback(this.callbacks.headerCellExporting,args);if(!noCancel){return}if(this.settings.gridStyling==="applied"){xlRow.getCellFormat(columnIndex).fill(this._headerFill);xlRow.getCellFormat(columnIndex).font().colorInfo(new $.ig.excel.WorkbookColorInfo(this._headersForeColor))}this._exportCell(xlRow,gridColumn,columnIndex,args.headerText);this._handleEventCallback(this.callbacks.headerCellExported,args)}this._xlRowIndex++;this._worksheet.displayOptions().frozenPaneSettings().frozenRows(this._xlRowIndex);this._worksheet.displayOptions().panesAreFrozen(true)},_exportDataSegment:function(){var xlRow,dataRow;this._exportedProps=[];this._subGridHeaderRowsIndices=[];this._colsIndices=[];var wasRowExportingCancelled=false;for(var rowIndex=0;rowIndex<this._dataToExport.length;rowIndex++){xlRow=this._worksheet.rows(this._xlRowIndex);dataRow=this._dataToExport[rowIndex];var args={element:this._dataRows[rowIndex],rowId:this._getGridRowId(dataRow,rowIndex),xlRow:xlRow,grid:this._gridWidget},noCancel=this._handleEventCallback(this.callbacks.rowExporting,args);if(!noCancel){wasRowExportingCancelled=true;continue}this._exportDataSegmentRow(xlRow,dataRow,rowIndex);this._handleEventCallback(this.callbacks.rowExported,args);this._xlRowIndex++;if(this._gridType==="igHierarchicalGrid"){if(!this._grid.expanded(args.element)&&this.settings.dataExportMode==="expandedRows"){continue}}this._goThroughChildren(dataRow,xlRow,rowIndex,1,args);this._exportedProps=[]}if(wasRowExportingCancelled){this._recalculateTableEnd();this._shouldResizeTableRegion=true}},_exportDataSegmentRow:function(xlRow,dataRow,rowIndex,indent,dataRowProp){var gridColumn,layoutColumns=[],columnLayout,dataCell,columnIndex,subgridColumnsNumber;if(indent===undefined){layoutColumns=this._columnsToExport}else{for(var y=0;y<this._allColumnLayoutsKeys.length;y++){if(dataRowProp===this._allColumnLayoutsKeys[y].key){columnLayout=this._allColumnLayoutsKeys[y];layoutColumns=columnLayout.columns}}}if(indent!==undefined&&this._gridType==="igHierarchicalGrid"){if(layoutColumns!==undefined&&layoutColumns.length>0){for(columnIndex=0;columnIndex<layoutColumns.length;columnIndex++){gridColumn=layoutColumns[columnIndex];if(this._colsIndices.indexOf(columnIndex)===-1){this._colsIndices.push(columnIndex)}dataCell=dataRow[gridColumn.key];this._exportCell(xlRow,gridColumn,columnIndex,dataCell,rowIndex,indent)}}else{subgridColumnsNumber=0;for(var prop in dataRow){if(prop!=="__metadata"&&prop!=="ig_pk"){if(typeof dataRow[prop]==="object"){continue}subgridColumnsNumber++;if(this._colsIndices.indexOf(subgridColumnsNumber-1)===-1){this._colsIndices.push(subgridColumnsNumber-1)}dataCell=dataRow[prop];this._exportCell(xlRow,gridColumn,subgridColumnsNumber-1,dataCell,rowIndex,indent)}}}}else{for(columnIndex=0;columnIndex<this._columnsToExport.length;columnIndex++){gridColumn=this._columnsToExport[columnIndex];dataCell=dataRow[gridColumn.key];if(this.settings.gridStyling==="applied"){xlRow.getCellFormat(columnIndex).fill(this._cellFill[xlRow.index()%2]);xlRow.getCellFormat(columnIndex).font().colorInfo(new $.ig.excel.WorkbookColorInfo(this._rowForeColor))}if(gridColumn.unbound&&gridColumn.formula===undefined&&dataCell===undefined){dataCell=this._gridWidget[this._gridType]("getCellText",this._getGridRowId(dataRow,rowIndex),gridColumn.key)}if(gridColumn.formatter!==undefined){dataCell=gridColumn.formatter(dataCell)}this._exportCell(xlRow,gridColumn,columnIndex,dataCell,rowIndex,indent)}}},_goThroughChildren:function(dataRow,xlRow,rowIndex,indent,args,parentDataRowProp,childRowIndex){var responseDataKey,dataRowObj,shouldContinue;if(this._dataToExport.indexOf(dataRow)===-1&&this._gridType==="igHierarchicalGrid"){this._exportChildGridHeaders(dataRow,xlRow,indent,parentDataRowProp)}shouldContinue=true;if(this._gridType==="igHierarchicalGrid"&&childRowIndex!==undefined&&this.settings.dataExportMode!=="allRows"){if(!this._grid.expanded($(args.element).siblings("[data-container='true']").find("tr").siblings("[role='row']")[childRowIndex])&&this.settings.dataExportMode==="expandedRows"){shouldContinue=false}}if(shouldContinue){for(var prop in dataRow){if(dataRow[prop]!==null&&dataRow.hasOwnProperty(prop)&&typeof dataRow[prop]==="object"&&prop!=="__metadata"&&prop!=="ig_pk"){for(var y=0;y<this._allColumnLayoutsKeys.length;y++){if(prop===this._allColumnLayoutsKeys[y].key){responseDataKey=this._allColumnLayoutsKeys[y].responseDataKey}}if(responseDataKey!==undefined){dataRowObj=dataRow[prop][responseDataKey]}else{dataRowObj=dataRow[prop]}if(dataRowObj!==undefined){for(var i=0;i<dataRowObj.length;i++){xlRow=this._worksheet.rows(this._xlRowIndex);xlRow.outlineLevel(indent);this._exportDataSegmentRow(xlRow,dataRowObj[i],rowIndex,indent,prop);this._handleEventCallback(this.callbacks.rowExported,args);this._xlRowIndex++;xlRow=this._worksheet.rows(this._xlRowIndex);this._goThroughChildren(dataRowObj[i],xlRow,rowIndex,indent+1,args,prop,i);this._recalculateTableEnd();this._shouldResizeTableRegion=true}}}}}},_getAllColumnLayoutKeys:function(obj){this._allColumnLayoutsKeys.push(obj);if(obj.columnLayouts!==undefined&&obj.columnLayouts.length){this._getAllColumnLayoutKeys(obj.columnLayouts[0])}},_exportChildGridHeaders:function(dataRow,xlRow,indent,parentDataRowProp){var subGridColumnIndex=0,columnLayout,gridColumn,layoutColumns=[],keysCounter=0,counter=0;this._columnLayoutKeys=[];for(var i=0;i<this._allColumnLayoutsKeys.length;i++){if(parentDataRowProp===this._allColumnLayoutsKeys[i].key){columnLayout=this._allColumnLayoutsKeys[i]}}if(columnLayout.columns!==undefined){layoutColumns=columnLayout.columns;for(var columnIndex=0;columnIndex<layoutColumns.length;columnIndex++){gridColumn=layoutColumns[columnIndex];if(this._exportedProps.indexOf(gridColumn.key)===-1){if(counter===0){this._worksheet.rows().insert(xlRow.index()-1,1);xlRow=this._worksheet.rows(xlRow.index()-2);xlRow.outlineLevel(indent-1)}xlRow.cells(0).cellFormat().indent((indent-1)*2);xlRow.cells(columnIndex).cellFormat().alignment($.ig.excel.HorizontalCellAlignment.left);xlRow.cells(columnIndex).cellFormat().font().bold(1);xlRow.setCellValue(columnIndex,gridColumn.key);this._exportedProps.push(gridColumn.key);if(this._subGridHeaderRowsIndices.indexOf(xlRow.index())===-1){this._subGridHeaderRowsIndices.push(xlRow.index())}if(counter===0){this._xlRowIndex++}counter++}}}else{for(var prop in dataRow){for(var y=0;y<this._allColumnLayoutsKeys.length;y++){if(prop===this._allColumnLayoutsKeys[y].key){keysCounter++}}if(keysCounter>0){continue}if(this._exportedProps.indexOf(prop)===-1&&prop!=="ig_pk"){if(counter===0){this._worksheet.rows().insert(xlRow.index()-1,1);xlRow=this._worksheet.rows(xlRow.index()-2);xlRow.outlineLevel(indent-1)}subGridColumnIndex++;xlRow.cells(0).cellFormat().indent((indent-1)*2);xlRow.cells(subGridColumnIndex-1).cellFormat().alignment($.ig.excel.HorizontalCellAlignment.left);xlRow.cells(subGridColumnIndex-1).cellFormat().font().bold(1);xlRow.setCellValue(subGridColumnIndex-1,prop);this._exportedProps.push(prop);if(this._subGridHeaderRowsIndices.indexOf(xlRow.index())===-1){this._subGridHeaderRowsIndices.push(xlRow.index())}if(counter===0){this._xlRowIndex++}counter++}}}},_exportCell:function(xlRow,gridColumn,columnIndex,cellValue,rowIndex,indent){var args={},noCancel;if(gridColumn){args={columnKey:gridColumn.key,columnIndex:columnIndex,xlRow:xlRow,cellValue:cellValue,grid:this._gridWidget};if(rowIndex!==undefined){args.rowId=this._getGridRowId(this._dataToExport[rowIndex],rowIndex)}}else{args={cellValue:cellValue,xlRow:xlRow,grid:this._gridWidget}}noCancel=this._handleEventCallback(this.callbacks.cellExporting,args);if(!noCancel){return}cellValue=args.cellValue;if(indent!==undefined&&columnIndex===0){xlRow.cells(columnIndex).cellFormat().indent(indent*2);xlRow.cells(columnIndex).cellFormat().alignment($.ig.excel.HorizontalCellAlignment.left);xlRow.setCellValue(columnIndex,cellValue)}else{xlRow.setCellValue(columnIndex,cellValue)}this._handleEventCallback(this.callbacks.cellExported,args)},_getGridRowId:function(dataRow,rowIndex){var rowId;if(this._grid.options.primaryKey!==null){rowId=dataRow[this._grid.options.primaryKey]}else{rowId=rowIndex}return rowId},_recalculateTableEnd:function(cols){cols=cols?cols:this._worksheetTable.columns().count();var xlRowIndex=this._xlRowIndex-1;this._tableRegionEndCellReference=$.ig.excel.WorksheetCell.getCellAddressString(this._worksheet.rows().item(xlRowIndex),cols-1,$.ig.excel.CellReferenceMode.a1,false).toString()},_resizeTableRegion:function(){var tableRegionStartCellReference=$.ig.excel.WorksheetCell.getCellAddressString(this._worksheet.rows().item(0),0,$.ig.excel.CellReferenceMode.a1,false).toString();if(tableRegionStartCellReference.substring(tableRegionStartCellReference.lastIndexOf("$")+1)===this._tableRegionEndCellReference.substring(this._tableRegionEndCellReference.lastIndexOf("$")+1)){var nextRowIndex=parseInt(this._tableRegionEndCellReference.substring(this._tableRegionEndCellReference.lastIndexOf("$")+1))+1;this._tableRegionEndCellReference=this._tableRegionEndCellReference.substring(0,this._tableRegionEndCellReference.lastIndexOf("$")+1)+nextRowIndex.toString()}this._worksheetTable.resize(tableRegionStartCellReference+":"+this._tableRegionEndCellReference)},_exportFeatures:function(){var features=this.settings.gridFeatureOptions;var featureName;for(var i=0;i<this._grid.options.features.length;i++){featureName=this._grid.options.features[i].name;if(features[featureName.toLowerCase()]===undefined){continue}if(featureName!=="Paging"&&featureName!=="Hiding"){if(features[featureName.toLowerCase()]!=="none"){this["_export"+featureName]()}}}},_getFeature:function(name){var features=this._grid.options.features;for(var featureIndex=0;featureIndex<features.length;featureIndex++){var feature=features[featureIndex];if(feature.name.toLowerCase()===name.toLowerCase()){return feature}}return null},_exportSorting:function(){var orderedSortConditions=this._createSortingConditions();var sortExpressions=this._grid.dataSource.settings.sorting.expressions;var columnToSort,sortDirection;for(var i=0;i<sortExpressions.length;i++){for(var j=0;j<this._columnsToExport.length;j++){if(sortExpressions[i].fieldName===this._columnsToExport[j].key){columnToSort=this._worksheetTable.columns().item(j);sortDirection=sortExpressions[i].dir;if(columnToSort!==undefined&&sortDirection!==undefined){this._worksheetTable.sortSettings().sortConditions().add(columnToSort,orderedSortConditions[sortDirection])}}}}},_createSortingConditions:function(){var orderedSortConditions={asc:new $.ig.excel.OrderedSortCondition($.ig.excel.SortDirection.ascending),desc:new $.ig.excel.OrderedSortCondition($.ig.excel.SortDirection.descending)};return orderedSortConditions},_exportFiltering:function(){if(this.settings.gridFeatureOptions.filtering==="filteredRowsOnly"){return}var filteringConditions=this._createFilteringConditions();var filtExpressions=this._grid.dataSource.settings.filtering.expressions;var columnToFilter,filtCond,filtExpr;if(filtExpressions.length>0){for(var i=0;i<filtExpressions.length;i++){for(var j=0;j<this._columnsToExport.length;j++){if(this._columnsToExport[j].key===filtExpressions[i].fieldName){columnToFilter=this._worksheetTable.columns().item(j);filtCond=filtExpressions[i].cond;filtExpr=filtExpressions[i].expr;switch(typeof filtExpr){case"string":columnToFilter.applyCustomFilter(new $.ig.excel.CustomFilterCondition(filteringConditions[filtCond],filtExpr));break;case"number":columnToFilter.applyCustomFilter(new $.ig.excel.CustomFilterCondition(filteringConditions[filtCond],filtExpr));break}}}}}},_createFilteringConditions:function(){var filteringConditions={equals:$.ig.excel.ExcelComparisonOperator.equals,doesNotEqual:$.ig.excel.ExcelComparisonOperator.notEqual,greaterThan:$.ig.excel.ExcelComparisonOperator.greaterThan,greaterThanOrEqualTo:$.ig.excel.ExcelComparisonOperator.greaterThanOrEqual,lessThan:$.ig.excel.ExcelComparisonOperator.lessThan,lessThanOrEqualTo:$.ig.excel.ExcelComparisonOperator.lessThanOrEqual,startsWith:$.ig.excel.ExcelComparisonOperator.beginsWith,endsWith:$.ig.excel.ExcelComparisonOperator.endsWith,contains:$.ig.excel.ExcelComparisonOperator.contains,doesNotContain:$.ig.excel.ExcelComparisonOperator.doesNotContain,"false":$.ig.excel.ExcelComparisonOperator.equals,"true":$.ig.excel.ExcelComparisonOperator.equals};return filteringConditions},_exportSummaries:function(){if(this._xlRowIndex===1){return}var argumentSeparator=this._getSummariesArgumentSeparator($.ig.CultureInfo.prototype.currentCulture().numberFormat().numberDecimalSeparator());var dataEndRowIndex=this._xlRowIndex-1;var summaries=this._gridWidget.igGridSummaries("summaryCollection");var worksheet=this._worksheet;for(var i=0;i<this._columnsToExport.length;i++){var columnIndex=i;var column=this._columnsToExport[columnIndex];if(summaries[column.key]===undefined){continue}var summariesForColumn=summaries[column.key];var dataStartRowIndex=1;var columnReference=new $.ig.excel.WorksheetRegion(this._worksheet,dataStartRowIndex,columnIndex,dataEndRowIndex,columnIndex).toString($.ig.excel.CellReferenceMode.a1,false,true,true);for(var summaryIndex=0;summaryIndex<summariesForColumn.length;summaryIndex++){var summary=summariesForColumn[summaryIndex],summaryType,formatString;switch(summary.type.toLowerCase()){case"avg":summaryType=101;formatString='"'+$.ig.GridSummaries.locale.defaultSummaryRowDisplayLabelAvg+' = "0.00';break;case"min":summaryType=105;formatString='"'+$.ig.GridSummaries.locale.defaultSummaryRowDisplayLabelMin+' = "0.00';break;case"max":summaryType=104;formatString='"'+$.ig.GridSummaries.locale.defaultSummaryRowDisplayLabelMax+' = "0.00';break;case"count":summaryType=103;formatString='"'+$.ig.GridSummaries.locale.defaultSummaryRowDisplayLabelCount+' = "0.00';break;case"sum":summaryType=109;formatString='"'+$.ig.GridSummaries.locale.defaultSummaryRowDisplayLabelSum+' = "0.00';break}var args={headerText:this._grid.options.columns[columnIndex].headerText,columnKey:this._grid.options.columns[columnIndex].key,columnIndex:columnIndex,summary:summariesForColumn[summaryIndex],xlRowIndex:this._xlRowIndex},noCancel=this._handleEventCallback(this.callbacks.summaryExporting,args);if(!noCancel){return}if(summaryType){var xlRow=worksheet.rows(this._xlRowIndex+summaryIndex);xlRow.applyCellFormula(columnIndex,"=SUBTOTAL("+summaryType+argumentSeparator+columnReference+")");xlRow.getCellFormat(columnIndex).formatString(formatString);this._handleEventCallback(this.callbacks.summaryExported,args)}}}},_getSummariesArgumentSeparator:function(decimalSeparator){if(decimalSeparator===","){return";"}return","},_exportColumnFixing:function(){var numberOfFrozenCols=0;for(var i=0;i<this._columnsToExport.length;i++){if(this._columnsToExport[i].fixed){numberOfFrozenCols++}}this._worksheet.displayOptions().frozenPaneSettings().frozenColumns(numberOfFrozenCols)},_calculateColumnsSize:function(){var gridFeatureOptions=this.settings.gridFeatureOptions,headers=this._gridWidget.find("thead").length>0?this._gridWidget.find("thead"):this._grid.headersTable().find("thead"),i,col,colWidth;for(i=0;i<this._columnsToExport.length;i++){var column=this._columnsToExport[i];if(this._getFeature("Hiding")&&gridFeatureOptions.hiding==="none"||column.fixed&&!column.hidden){col=this._worksheet.columns().item(i);colWidth=column.width;if(colWidth&&!column.hidden){if(!isNaN(colWidth)){col.setWidth(colWidth,$.ig.excel.WorksheetColumnWidthUnit.pixel)}else if(isNaN(colWidth)){var widthSize=colWidth.match(/\d+/)[0];if(colWidth.contains("px")){col.setWidth(widthSize,$.ig.excel.WorksheetColumnWidthUnit.pixel)}else{col.setWidth(widthSize/100*this._gridWidget.width(),$.ig.excel.WorksheetColumnWidthUnit.pixel)}}}}else{col=this._worksheet.columns().item(i);var colElemId=this._gridWidget.attr("id")+"_"+column.key;colWidth=$(headers).find('[id="'+colElemId+'"]').width();col.setWidth(colWidth,$.ig.excel.WorksheetColumnWidthUnit.pixel)}}},_getCellFill:function(){this._cellFill=[];this._cellFill.push($.ig.excel.CellFill.createSolidFill(this._altRowColor));this._cellFill.push($.ig.excel.CellFill.createSolidFill(this._notAltRowColor));return this._cellFill},_styleChildGridHeaders:function(){if(this._gridType==="igHierarchicalGrid"&&this._colsIndices&&this._colsIndices.length>0){this._recalculateTableEnd(this._colsIndices.length);this._resizeTableRegion();if(this.settings.gridStyling==="applied"){for(var i=1;i<this._worksheetRegion.lastRow()+1;i++){for(var y=0;y<this._colsIndices.length;y++){if(this._subGridHeaderRowsIndices.indexOf(i)!==-1){this._worksheet.rows(this._subGridHeaderRowsIndices[this._subGridHeaderRowsIndices.indexOf(i)]).getCellFormat(y).fill(this._headerFill);this._worksheet.rows(this._subGridHeaderRowsIndices[this._subGridHeaderRowsIndices.indexOf(i)]).getCellFormat(y).font().colorInfo(new $.ig.excel.WorkbookColorInfo(this._headersForeColor))}else{this._worksheet.rows(i).getCellFormat(y).fill(this._cellFill[i%2]);this._worksheet.rows(i).getCellFormat(y).font().colorInfo(new $.ig.excel.WorkbookColorInfo(this._rowForeColor))}}}}}},_saveWorkbook:function(){var self=this;setTimeout(function(){self._workbook.save({type:"blob"},function(data){saveAs(data,self.settings.fileName+".xlsx");self._handleEventCallback(self.callbacks.success,data)},function(err){self._handleEventCallback(self.callbacks.error,err)})},1)},_handleEventCallback:function(callback,args){if(!$.isFunction(callback)){return true}var noCancel=callback(this,args);if(noCancel===false){return false}return true}});$.ig.GridExcelExporter.exportGrid=function(grid,userSettings,userCallbacks){var exp=new $.ig.GridExcelExporter;exp.exportGrid(grid,userSettings,userCallbacks);exp=null}})(jQuery);