all files / pivotview/actions/ excel-export.js

90.88% Statements 249/274
80.45% Branches 251/312
100% Functions 10/10
90.88% Lines 249/274
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449   35× 35× 35× 35× 35× 35× 35× 35×   2148×   10×     10× 10× 10× 10× 10× 21× 21× 21× 21× 21×             21×     21× 21×   21× 21×   10×                             22× 22× 22× 22× 22× 22× 22×     22× 20× 20× 20× 20×         22× 22× 22× 22× 22× 22× 22× 22× 22× 22× 13× 13× 13× 13×       13×   13× 13× 13× 13× 13× 13× 13×         22×     22× 22× 22× 22× 22× 22× 22× 22× 22×   22× 21×     21×   21×   22×   22× 22× 22×             22× 22× 22× 22× 22× 22× 22×   22× 22× 209×   187×     22× 2660× 2654× 2654×           2654× 2654× 2654× 38692× 38646× 38646×         38646× 38646× 38646× 38645× 38645× 38645×   38645× 37×   38608×     38604×     38645× 38645×       38645× 38645× 35727×   9290×   35727× 35727×     2918× 2918×     2608× 2608× 2476× 2476× 2476×     132× 132× 132×   132×   132× 132× 132×       38645×   1020×   1020×   1020×   1020×   1020×       38645× 38645× 38645× 38645× 310×           310×     38335×                   38335×   38645×     38645×   38645×       38645×         38645×     38645× 310× 310×     38335×   38335×       38646×     46× 46× 22×         22× 22×     46× 46× 46×       46×   46× 46×       46×       46×             2654× 2654×   2654×     22× 21×   16×     16×       22× 21× 21× 203× 203×     203×     22×   22×   22× 22×   22× 22× 20× 20× 20× 20×           18×       18× 18×   20×                     35× 35× 35× 13×   35× 35×          
define(["require", "exports", "@syncfusion/ej2-excel-export", "../../common/base/constant", "@syncfusion/ej2-base", "../../base/export-util", "./excel-export-helper"], function (require, exports, ej2_excel_export_1, events, ej2_base_1, export_util_1, excel_export_helper_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var ExcelExport = (function () {
        function ExcelExport(parent) {
            this.actualrCnt = 0;
            this.images = [];
            this.workSheet = [];
            this.isHeaderIncluded = false;
            this.book = {};
            this.parent = parent;
            this.excelExportHelper = new excel_export_helper_1.ExcelExportHelper(this.parent);
            this.rows = [];
        }
        ExcelExport.prototype.getModuleName = function () {
            return 'excelExport';
        };
        ExcelExport.prototype.addHeaderAndFooter = function (excelExportProperties, stringValue, type, rowCount) {
            Iif (!this.rows) {
                this.rows = [];
            }
            var cells = [];
            Eif (!ej2_base_1.isNullOrUndefined(excelExportProperties.rows)) {
                this.actualrCnt = (type === 'footer') ? this.actualrCnt + rowCount - (excelExportProperties.rows[0].cells.length) : this.actualrCnt;
                var row = excelExportProperties.rows;
                for (var i = 0; i < row.length; i++) {
                    var spanCount = 0;
                    cells = [];
                    var currentRow = row[i];
                    for (var j = 0; j < currentRow.cells.length; j++) {
                        var cell = {
                            index: spanCount + 1, value: currentRow.cells[j].value,
                            colSpan: currentRow.cells[j].colSpan, rowSpan: currentRow.cells[j].rowSpan,
                            style: !ej2_base_1.isNullOrUndefined(this.theme) && !ej2_base_1.isNullOrUndefined(this.theme.caption) ?
                                this.excelExportHelper.getCaptionThemeStyle(this.theme, currentRow.cells[j].style)
                                : currentRow.cells[j].style
                        };
                        if (currentRow.cells[j].hyperlink) {
                            cell.hyperlink = { target: currentRow.cells[j].hyperlink.target };
                            cell.value = currentRow.cells[j].value ? currentRow.cells[j].value :
                                currentRow.cells[j].hyperlink.displayText;
                        }
                        cells.push(cell);
                        spanCount = spanCount + cells[j].colSpan;
                    }
                    this.actualrCnt++;
                    this.rows.push({ index: this.actualrCnt, cells: cells });
                }
                this.actualrCnt = (type === 'header') ? rowCount : this.actualrCnt;
            }
            else {
                if (stringValue !== '') {
                    if (type === 'footer') {
                        this.actualrCnt++;
                    }
                    cells.push({
                        index: 1, value: stringValue
                    });
                    this.rows.push({ index: this.actualrCnt + 1, cells: cells });
                    this.actualrCnt = (type === 'header') ? this.actualrCnt + 2 : this.actualrCnt;
                }
            }
        };
        ExcelExport.prototype.exportToExcel = function (type, exportProperties, isBlob, workBook, isMultipleExport, currentPivotInstance) {
            var _this = this;
            return new Promise(function (resolve, reject) {
                try {
                    _this.actualrCnt = 0;
                    var expType = 'AppendToSheet';
                    var blankRows = 5;
                    if (!ej2_base_1.isNullOrUndefined(exportProperties) && !ej2_base_1.isNullOrUndefined(exportProperties.multipleExport)) {
                        expType = (!ej2_base_1.isNullOrUndefined(exportProperties.multipleExport.type) ? exportProperties.multipleExport.type : 'AppendToSheet');
                        if (!ej2_base_1.isNullOrUndefined(exportProperties.multipleExport.blankRows)) {
                            blankRows = exportProperties.multipleExport.blankRows;
                        }
                    }
                    if (ej2_base_1.isNullOrUndefined(workBook)) {
                        _this.workSheet = [];
                        _this.rows = [];
                        _this.columns = [];
                        _this.images = [];
                    }
                    else if (expType === 'NewSheet') {
                        _this.rows = [];
                        _this.columns = [];
                        _this.images = [];
                    }
                    else {
                        _this.workSheet = [];
                        _this.rows = workBook['worksheets'][0].rows;
                        _this.columns = workBook['worksheets'][0].columns;
                        _this.images = workBook['worksheets'][0].images;
                        _this.actualrCnt = (_this.rows[_this.rows.length - 1].index + (blankRows - 1));
                        _this.actualrCnt++;
                    }
                    _this.parent = currentPivotInstance ? currentPivotInstance : _this.parent;
                    var isHeaderDefined = !ej2_base_1.isNullOrUndefined(exportProperties) && !ej2_base_1.isNullOrUndefined(exportProperties.header);
                    var isFooterDefined = !ej2_base_1.isNullOrUndefined(exportProperties) && !ej2_base_1.isNullOrUndefined(exportProperties.footer);
                    var isFileNameDefined = !ej2_base_1.isNullOrUndefined(exportProperties) && !ej2_base_1.isNullOrUndefined(exportProperties.fileName);
                    _this.engine = _this.parent.dataType === 'olap' ? _this.parent.olapEngineModule : _this.parent.engineModule;
                    _this.theme = !ej2_base_1.isNullOrUndefined(exportProperties) ? exportProperties.theme : undefined;
                    var clonedValues = void 0;
                    var currentPivotValues = export_util_1.PivotExportUtil.getClonedPivotValues(_this.engine.pivotValues);
                    var customFileName = isFileNameDefined ? exportProperties.fileName : type === 'CSV' ? 'default.csv' : 'default.xlsx';
                    if (_this.parent.exportAllPages && (_this.parent.enableVirtualization || _this.parent.enablePaging)) {
                        var pageSettings = _this.engine.pageSettings;
                        var mdxQuery = void 0;
                        _this.engine.isPagingOrVirtualizationEnabled = false;
                        if (_this.parent.dataType === 'olap') {
                            _this.updateOlapPageSettings(true);
                            mdxQuery = _this.parent.olapEngineModule.mdxQuery.slice(0);
                        }
                        else {
                            _this.engine.pageSettings = null;
                        }
                        var dataSourceSettings = !ej2_base_1.isNullOrUndefined(currentPivotInstance) ?
                            currentPivotInstance.dataSourceSettings : _this.parent.dataSourceSettings;
                        _this.engine.generateGridData(dataSourceSettings, true, true);
                        _this.parent.applyFormatting(_this.engine.pivotValues, dataSourceSettings);
                        clonedValues = export_util_1.PivotExportUtil.getClonedPivotValues(_this.engine.pivotValues);
                        _this.engine.pivotValues = currentPivotValues;
                        _this.engine.pageSettings = pageSettings;
                        _this.engine.isPagingOrVirtualizationEnabled = true;
                        if (_this.parent.dataType === 'olap') {
                            _this.updateOlapPageSettings(false);
                            _this.parent.olapEngineModule.mdxQuery = mdxQuery;
                        }
                    }
                    else {
                        clonedValues = currentPivotValues;
                    }
                    var args = {
                        fileName: customFileName, header: '', footer: '', dataCollections: [clonedValues], excelExportProperties: exportProperties
                    };
                    var fileName_1;
                    var header_1;
                    var footer_1;
                    var dataCollections_1;
                    _this.parent.trigger(events.beforeExport, args, function (observedArgs) {
                        fileName_1 = observedArgs.fileName;
                        header_1 = observedArgs.header;
                        footer_1 = observedArgs.footer;
                        dataCollections_1 = observedArgs.dataCollections;
                    });
                    if ((!_this.isHeaderIncluded && expType === 'AppendToSheet') || (expType === 'NewSheet')) {
                        Iif (!isHeaderDefined && ej2_base_1.isNullOrUndefined(args.excelExportProperties) && header_1 !== '') {
                            _this.addHeaderAndFooter({}, header_1, 'header', undefined);
                        }
                        else if (!ej2_base_1.isNullOrUndefined(args.excelExportProperties) && !ej2_base_1.isNullOrUndefined(args.excelExportProperties.header)) {
                            _this.addHeaderAndFooter(args.excelExportProperties.header, '', 'header', args.excelExportProperties.header.headerRows);
                        }
                        _this.isHeaderIncluded = true;
                    }
                    var includeHiddenColumn = args.excelExportProperties && args.excelExportProperties.includeHiddenColumn ?
                        args.excelExportProperties.includeHiddenColumn : true;
                    var col = currentPivotInstance ? currentPivotInstance.grid.getColumns() : _this.parent.grid.getColumns();
                    var hiddenColumnsIndex = [];
                    Iif (!includeHiddenColumn) {
                        for (var column = 0; column < col.length; column++) {
                            if (!col[column].visible) {
                                hiddenColumnsIndex.push(column);
                            }
                        }
                    }
                    var columnCount = 0;
                    var rowHeight = 0;
                    for (var dataColl = 0; dataColl < dataCollections_1.length; dataColl++) {
                        var pivotValues = dataCollections_1[dataColl];
                        var colLen = 0;
                        var rowLen = pivotValues.length;
                        var formatList = currentPivotInstance ? currentPivotInstance.renderModule.formatList
                            : _this.parent.renderModule.formatList;
                        var maxLevel = 0;
                        for (var colCount = 0; colCount < pivotValues[0].length; colCount++) {
                            if (pivotValues[0][colCount] !== null &&
                                pivotValues[0][colCount] !== undefined) {
                                columnCount++;
                            }
                        }
                        for (var rCnt = 0; rCnt < rowLen; rCnt++) {
                            if (pivotValues[rCnt]) {
                                _this.actualrCnt++;
                                Iif (!includeHiddenColumn) {
                                    for (var _i = 0, hiddenColumnsIndex_1 = hiddenColumnsIndex; _i < hiddenColumnsIndex_1.length; _i++) {
                                        var colIndex = hiddenColumnsIndex_1[_i];
                                        pivotValues[rCnt].splice(colIndex, 1);
                                    }
                                }
                                colLen = pivotValues[rCnt].length;
                                var cells = [];
                                for (var cCnt = 0; cCnt < colLen; cCnt++) {
                                    if (pivotValues[rCnt][cCnt]) {
                                        var pivotCell = pivotValues[rCnt][cCnt];
                                        var field = (_this.parent.dataSourceSettings.valueAxis === 'row' &&
                                            _this.parent.dataType === 'olap' && pivotCell.rowOrdinal &&
                                            _this.engine.tupRowInfo[pivotCell.rowOrdinal]) ?
                                            _this.engine.tupRowInfo[pivotCell.rowOrdinal].measureName :
                                            pivotCell.actualText;
                                        var styles = (pivotCell.axis === 'row') ? { hAlign: 'Left', bold: true, wrapText: true } : { numberFormat: formatList[field], bold: false, wrapText: true };
                                        var headerStyle = { bold: true, vAlign: 'Center', wrapText: true, indent: cCnt === 0 ? pivotCell.level * 10 : 0 };
                                        if (!(pivotCell.level === -1 && !pivotCell.rowSpan)) {
                                            var aggMatrix = _this.engine.aggregatedValueMatrix;
                                            var cellValue = pivotCell.axis === 'value' ? ((aggMatrix[rCnt] && aggMatrix[rCnt][cCnt]) ? aggMatrix[rCnt][cCnt] : (pivotCell.formattedText === '#DIV/0!' ? pivotCell.formattedText : pivotCell.value)) : pivotCell.formattedText;
                                            var isgetValuesHeader = ((_this.parent.dataSourceSettings.rows.length === 0 && _this.parent.dataSourceSettings.valueAxis === 'row')
                                                || (_this.parent.dataSourceSettings.columns.length === 0 && _this.parent.dataSourceSettings.valueAxis === 'column'));
                                            if (pivotCell.type === 'grand sum' && !(_this.parent.dataSourceSettings.values.length === 1 && _this.parent.dataSourceSettings.valueAxis === 'row' && pivotCell.axis === 'column')) {
                                                cellValue = isgetValuesHeader ? _this.parent.getValuesHeader(pivotCell, 'grandTotal') : _this.parent.localeObj.getConstant('grandTotal');
                                            }
                                            else if (pivotCell.type === 'sum') {
                                                cellValue = cellValue.toString().replace('Total', _this.parent.localeObj.getConstant('total'));
                                            }
                                            else {
                                                cellValue = (!ej2_base_1.isNullOrUndefined(pivotCell.valueSort) && (_this.parent.localeObj.getConstant('grandTotal') + _this.parent.dataSourceSettings.valueSortSettings.headerDelimiter + pivotCell.formattedText
                                                    === pivotCell.valueSort.levelName) && isgetValuesHeader) ? _this.parent.getValuesHeader(pivotCell, 'value') : cellValue;
                                            }
                                            Eif (!(pivotCell.level === -1 && !pivotCell.rowSpan) && pivotCell.rowSpan !== 0) {
                                                cells.push({
                                                    index: cCnt + 1, value: cellValue,
                                                    colSpan: pivotCell.colSpan, rowSpan: (pivotCell.rowSpan === -1 ? 1 : pivotCell.rowSpan)
                                                });
                                                var lastCell = cells[cells.length - 1];
                                                if (pivotCell.axis === 'value') {
                                                    if (isNaN(pivotCell.value) || pivotCell.formattedText === '' ||
                                                        pivotCell.formattedText === undefined || ej2_base_1.isNullOrUndefined(pivotCell.value)) {
                                                        lastCell.value = type === 'Excel' ? null : '';
                                                    }
                                                    styles.numberFormat = typeof cellValue === 'string' ? undefined : styles.numberFormat;
                                                    lastCell.style = styles;
                                                }
                                                else {
                                                    lastCell.style = headerStyle;
                                                    if (pivotCell.axis === 'row' &&
                                                        (_this.parent.isTabular ? cCnt < _this.parent.engineModule.rowMaxLevel + 1 :
                                                            cCnt === 0)) {
                                                        lastCell.style = styles;
                                                        if (_this.parent.dataType === 'olap') {
                                                            var indent = _this.parent.renderModule.indentCollection[rCnt];
                                                            lastCell.style.indent = indent * 2;
                                                            maxLevel = maxLevel > indent ? maxLevel : indent;
                                                        }
                                                        else {
                                                            var levelName = pivotCell.valueSort ? pivotCell.valueSort.levelName.toString() : '';
                                                            var delimiter = _this.parent.dataSourceSettings.valueSortSettings.headerDelimiter;
                                                            var memberPos = pivotCell.actualText ?
                                                                pivotCell.actualText.toString().split(delimiter).length : 0;
                                                            var levelPosition = levelName.split(delimiter).length -
                                                                (memberPos ? memberPos - 1 : memberPos);
                                                            var level = levelPosition ? (levelPosition - 1) : 0;
                                                            lastCell.style.indent = level * 2;
                                                            maxLevel = level > maxLevel ? level : maxLevel;
                                                        }
                                                    }
                                                }
                                                if (pivotCell.style || lastCell.style.backColor || lastCell.style.fontColor ||
                                                    lastCell.style.fontName || lastCell.style.fontSize) {
                                                    lastCell.style.backColor = lastCell.style.backColor ? lastCell.style.backColor
                                                        : pivotCell.style.backgroundColor;
                                                    lastCell.style.fontColor = lastCell.style.fontColor ? lastCell.style.fontColor
                                                        : pivotCell.style.color;
                                                    lastCell.style.fontName = lastCell.style.fontName ? lastCell.style.fontName
                                                        : pivotCell.style.fontFamily;
                                                    Eif (!ej2_base_1.isNullOrUndefined(lastCell.style.fontSize) ||
                                                        !ej2_base_1.isNullOrUndefined(pivotCell.style.fontSize)) {
                                                        lastCell.style.fontSize = !ej2_base_1.isNullOrUndefined(lastCell.style.fontSize) ?
                                                            Number(lastCell.style.fontSize) : Number(pivotCell.style.fontSize.split('px')[0]);
                                                    }
                                                }
                                                lastCell.style.borders = { color: '#000000', lineStyle: 'thin' };
                                                var excelHeaderQueryCellInfoArgs = void 0;
                                                var excelQueryCellInfoArgs = void 0;
                                                if (pivotCell.axis === 'column') {
                                                    excelHeaderQueryCellInfoArgs = {
                                                        style: !ej2_base_1.isNullOrUndefined(_this.theme) && !ej2_base_1.isNullOrUndefined(_this.theme.header) ?
                                                            _this.excelExportHelper.getHeaderThemeStyle(_this.theme, headerStyle)
                                                            : headerStyle,
                                                        cell: pivotCell
                                                    };
                                                    _this.parent.trigger(events.excelHeaderQueryCellInfo, excelHeaderQueryCellInfoArgs);
                                                }
                                                else {
                                                    excelQueryCellInfoArgs = {
                                                        style: !ej2_base_1.isNullOrUndefined(_this.theme) && !ej2_base_1.isNullOrUndefined(_this.theme.record) ?
                                                            _this.excelExportHelper.getRecordThemeStyle(_this.theme, styles)
                                                            : styles,
                                                        cell: pivotCell,
                                                        column: undefined,
                                                        data: pivotValues,
                                                        value: cellValue,
                                                        colSpan: 1
                                                    };
                                                    _this.parent.trigger(events.excelQueryCellInfo, excelQueryCellInfoArgs);
                                                }
                                                lastCell.value = (pivotCell.axis === 'column') ?
                                                    excelHeaderQueryCellInfoArgs.cell.formattedText :
                                                    excelQueryCellInfoArgs.value;
                                                lastCell.style = (pivotCell.axis === 'column') ? excelHeaderQueryCellInfoArgs.style
                                                    : excelQueryCellInfoArgs.style;
                                                if ((excelHeaderQueryCellInfoArgs && excelHeaderQueryCellInfoArgs.image) ||
                                                    (excelQueryCellInfoArgs && excelQueryCellInfoArgs.image)) {
                                                    rowHeight = _this.excelExportHelper.setImage((pivotCell.axis === 'column') ?
                                                        excelHeaderQueryCellInfoArgs : excelQueryCellInfoArgs, cCnt, _this.actualrCnt, rowHeight);
                                                }
                                                Iif (!ej2_base_1.isNullOrUndefined(excelHeaderQueryCellInfoArgs) &&
                                                    !ej2_base_1.isNullOrUndefined(excelHeaderQueryCellInfoArgs.hyperLink)) {
                                                    lastCell.hyperlink = { target: excelHeaderQueryCellInfoArgs.hyperLink.target };
                                                    lastCell.value = excelHeaderQueryCellInfoArgs.hyperLink.displayText || lastCell.value;
                                                }
                                                else if (!ej2_base_1.isNullOrUndefined(excelQueryCellInfoArgs) &&
                                                    !ej2_base_1.isNullOrUndefined(excelQueryCellInfoArgs.hyperLink)) {
                                                    lastCell.hyperlink = { target: excelQueryCellInfoArgs.hyperLink.target };
                                                    lastCell.value = excelQueryCellInfoArgs.hyperLink.displayText || lastCell.value;
                                                }
                                                if (pivotCell.axis === 'column') {
                                                    lastCell.colSpan = excelHeaderQueryCellInfoArgs.cell.colSpan;
                                                    lastCell.rowSpan = excelHeaderQueryCellInfoArgs.cell.rowSpan;
                                                }
                                                else {
                                                    lastCell.colSpan = excelQueryCellInfoArgs.colSpan > 1 ? excelQueryCellInfoArgs.colSpan :
                                                        excelQueryCellInfoArgs.cell.colSpan;
                                                    lastCell.rowSpan = excelQueryCellInfoArgs.cell.rowSpan;
                                                }
                                            }
                                        }
                                        cCnt = cCnt + (pivotCell.colSpan ? (pivotCell.colSpan - 1) : 0);
                                    }
                                    else {
                                        var pivotCell = { formattedText: '', colSpan: 1, rowSpan: 1 };
                                        if (rCnt === 0 && cCnt === 0) {
                                            Iif (!includeHiddenColumn) {
                                                pivotCell.colSpan = pivotValues[0].length - (columnCount - hiddenColumnsIndex.length);
                                                pivotCell.rowSpan = Object.keys(pivotValues).length - _this.engine.rowCount;
                                            }
                                            else {
                                                pivotCell.colSpan = pivotValues[0].length - _this.engine.columnCount;
                                                pivotCell.rowSpan = Object.keys(pivotValues).length - _this.engine.rowCount;
                                            }
                                        }
                                        var excelHeaderQueryCellInfoArgs = void 0;
                                        Eif (pivotCell) {
                                            excelHeaderQueryCellInfoArgs = {
                                                style: { borders: { color: '#000000', lineStyle: 'thin' } },
                                                cell: pivotCell
                                            };
                                            _this.parent.trigger(events.excelHeaderQueryCellInfo, excelHeaderQueryCellInfoArgs);
                                        }
                                        var cell = excelHeaderQueryCellInfoArgs.cell;
                                        cells.push({
                                            index: cCnt + 1, colSpan: cell['colSpan'], rowSpan: cell['rowSpan'],
                                            value: pivotCell.formattedText, style: excelHeaderQueryCellInfoArgs.style
                                        });
                                        Iif (excelHeaderQueryCellInfoArgs.image) {
                                            rowHeight =
                                                _this.excelExportHelper.setImage(excelHeaderQueryCellInfoArgs, cCnt, _this.actualrCnt, rowHeight);
                                        }
                                        Iif (!ej2_base_1.isNullOrUndefined(excelHeaderQueryCellInfoArgs) &&
                                            !ej2_base_1.isNullOrUndefined(excelHeaderQueryCellInfoArgs.hyperLink)) {
                                            cell.hyperlink = { target: excelHeaderQueryCellInfoArgs.hyperLink.target };
                                            cell.value = excelHeaderQueryCellInfoArgs.hyperLink.displayText || cell.value;
                                        }
                                    }
                                }
                                var row = { index: _this.actualrCnt, cells: cells };
                                if (rowHeight > 0) {
                                    row.height = rowHeight;
                                    rowHeight = 0;
                                }
                                _this.rows.push(row);
                            }
                        }
                        if ((!isMultipleExport && expType === 'AppendToSheet') || expType === 'NewSheet') {
                            if (isFooterDefined) {
                                _this.addHeaderAndFooter(exportProperties.footer, '', 'footer', exportProperties.footer.footerRows);
                            }
                            else Iif (!isFooterDefined && footer_1 !== '' && ej2_base_1.isNullOrUndefined(args.excelExportProperties)) {
                                _this.addHeaderAndFooter({}, footer_1, 'footer', undefined);
                            }
                            else Iif (!ej2_base_1.isNullOrUndefined(args.excelExportProperties) && !ej2_base_1.isNullOrUndefined(args.excelExportProperties.footer)) {
                                _this.addHeaderAndFooter(args.excelExportProperties.footer, '', 'footer', args.excelExportProperties.footer.footerRows);
                            }
                        }
                        if (_this.columns.length < col.length) {
                            _this.columns = [];
                            for (var cCnt = 0; cCnt < colLen; cCnt++) {
                                var width = col[cCnt].width;
                                Iif (typeof (width) === 'string' && width.indexOf('px') !== -1) {
                                    width = parseInt(width, 10);
                                }
                                _this.columns.push({ index: cCnt + 1, width: width });
                            }
                        }
                        if (maxLevel > 0) {
                            _this.columns[0].width = 100 + (maxLevel * 20);
                        }
                        var sheet = { columns: _this.columns, rows: _this.rows, images: _this.images,
                            enableRtl: _this.parent.enableRtl };
                        _this.workSheet.push(sheet);
                        _this.book['worksheets'] = _this.workSheet;
                    }
                    var blobData = void 0;
                    if (!isMultipleExport) {
                        var book = new ej2_excel_export_1.Workbook(_this.book, type === 'Excel' ? 'xlsx' : 'csv', undefined, _this.parent.currencyCode);
                        var fileExtension = fileName_1.split('.').pop();
                        Eif (!isBlob) {
                            book.save(fileExtension === 'xlsx' || fileExtension === 'csv' ? fileName_1 : (fileName_1 + (type === 'Excel' ? '.xlsx' : '.csv')));
                        }
                        else {
                            blobData = book.saveAsBlob(fileExtension === 'xlsx' || type === 'Excel' ?
                                'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' : 'text/csv');
                        }
                        var exportCompleteEventArgs = {
                            type: type,
                            promise: isBlob ? blobData : null
                        };
                        _this.parent.trigger(events.exportComplete, exportCompleteEventArgs);
                        _this.isHeaderIncluded = false;
                    }
                    resolve(_this.book);
                }
                catch (error) {
                    reject(error);
                }
            });
        };
        ExcelExport.prototype.updateOlapPageSettings = function (isUpdate) {
            this.parent.olapEngineModule.isExporting = isUpdate ? true : false;
            if (!this.parent.exportSpecifiedPages) {
                this.parent.olapEngineModule.pageSettings = isUpdate ? null : this.parent.olapEngineModule.pageSettings;
                this.parent.olapEngineModule.isPaging = isUpdate ? false : true;
            }
            else {
                this.parent.olapEngineModule.exportSpeciedPages = this.parent.exportSpecifiedPages = isUpdate ?
                    this.parent.exportSpecifiedPages : undefined;
            }
        };
        ExcelExport.prototype.destroy = function () {
            this.rows = [];
            this.actualrCnt = 0;
            if (this.engine) {
                this.engine = null;
            }
            Eif (this.rows) {
                this.rows = null;
            }
        };
        return ExcelExport;
    }());
    exports.ExcelExport = ExcelExport;
});