all files / workbook/base/ column.js

93.98% Statements 78/83
90.79% Branches 69/76
100% Functions 17/17
94.74% Lines 72/76
18 statements, 7 functions, 29 branches Ignored     
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                                                  344939× 344939× 3298×             344939×   196× 196× 204×     640811× 640811× 146947× 477×   146470×       493864×   640334×         640334×     51614× 51614× 51614×   51614× 239518×   51614×   4294682×   6465× 116× 115×     6350×      
/* istanbul ignore next */ 
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
/* istanbul ignore next */ 
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
define(["require", "exports", "@syncfusion/ej2-base", "../common/index"], function (require, exports, ej2_base_1, index_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var Column = (function (_super) {
        __extends(Column, _super);
        function Column() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        __decorate([
            ej2_base_1.Property(0)
        ], Column.prototype, "index", void 0);
        __decorate([
            ej2_base_1.Property(64)
        ], Column.prototype, "width", void 0);
        __decorate([
            ej2_base_1.Property(false)
        ], Column.prototype, "customWidth", void 0);
        __decorate([
            ej2_base_1.Property(false)
        ], Column.prototype, "hidden", void 0);
        __decorate([
            ej2_base_1.Complex({}, index_1.Format)
        ], Column.prototype, "format", void 0);
        __decorate([
            ej2_base_1.Property(true)
        ], Column.prototype, "isLocked", void 0);
        __decorate([
            ej2_base_1.Property('')
        ], Column.prototype, "validation", void 0);
        __decorate([
            ej2_base_1.Property(false)
        ], Column.prototype, "isReadOnly", void 0);
        return Column;
    }(ej2_base_1.ChildProperty));
    exports.Column = Column;
    function getColumn(sheet, colIndex) {
        Eif (sheet.columns) {
            if (!sheet.columns[colIndex]) {
                sheet.columns[colIndex] = {};
            }
        }
        else {
            sheet.columns = [];
            sheet.columns[colIndex] = {};
        }
        return sheet.columns[colIndex];
    }
    exports.getColumn = getColumn;
    function setColumn(sheet, colIndex, column) {
        var curColumn = getColumn(sheet, colIndex);
        Object.keys(column).forEach(function (key) {
            curColumn["" + key] = column["" + key];
        });
    }
    exports.setColumn = setColumn;
    function getColumnWidth(sheet, index, skipHidden, checkDPR) {
        var width;
        if (sheet && sheet.columns && sheet.columns[index]) {
            if (!skipHidden && sheet.columns[index].hidden) {
                return 0;
            }
            width = (sheet.columns[index].width || sheet.columns[index].customWidth) ?
                sheet.columns[index].width : 64;
        }
        else {
            width = 64;
        }
        Iif (checkDPR && window.devicePixelRatio % 1 > 0) {
            var pointValue = (width * window.devicePixelRatio) % 1;
            return width + (pointValue ? ((pointValue > 0.5 ? (1 - pointValue) : -1 * pointValue) / window.devicePixelRatio) : 0);
        }
        else {
            return width;
        }
    }
    exports.getColumnWidth = getColumnWidth;
    function getColumnsWidth(sheet, startCol, endCol, checkDPR) {
        Iif (endCol === void 0) { endCol = startCol; }
        var width = 0;
        if (startCol > endCol) {
            var swap = startCol;
            startCol = endCol;
            endCol = swap;
        }
        for (var i = startCol; i <= endCol; i++) {
            width += getColumnWidth(sheet, i, null, checkDPR);
        }
        return width;
    }
    exports.getColumnsWidth = getColumnsWidth;
    function isHiddenCol(sheet, index) {
        return sheet.columns[index] && sheet.columns[index].hidden;
    }
    exports.isHiddenCol = isHiddenCol;
    function checkColumnValidation(column, rowIndex, colIndex) {
        if (column && column.validation) {
            if (!column.validation.address || (column.validation.address && index_1.isInMultipleRange(column.validation.address, rowIndex, colIndex))) {
                return true;
            }
        }
        return false;
    }
    exports.checkColumnValidation = checkColumnValidation;
});