@syncfusion/ej2-spreadsheet
Version:
Feature-rich JavaScript Spreadsheet (Excel) control with built-in support for selection, editing, formatting, importing and exporting to Excel
1,596 lines (1,589 loc) • 3.41 MB
JavaScript
import { isNullOrUndefined, ChildProperty, Property, Complex, getNumericObject, isUndefined as isUndefined$1, Internationalization, getNumberDependable, defaultCurrencyCode, IntlBase, cldrData, extend, Collection, getUniqueID, detach, getValue, Base, Event as Event$1, NotifyPropertyChanges, getComponent, closest, Component, L10n, merge, removeClass, Browser, setStyleAttribute as setStyleAttribute$1, attributes, formatUnit, addClass, append, compile, remove, EventHandler, select, initializeCSPTemplate, isObject, getInstance, createElement, selectAll, rippleEffect, enableRipple, classList } from '@syncfusion/ej2-base';
import { Query, Predicate, DataManager, Deferred, DataUtil } from '@syncfusion/ej2-data';
import { Tooltip, Dialog as Dialog$1, calculatePosition, isCollide, createSpinner, showSpinner, hideSpinner } from '@syncfusion/ej2-popups';
import { Tab, TreeView, Toolbar, Item, MenuItem, Menu, ContextMenu as ContextMenu$1 } from '@syncfusion/ej2-navigations';
import { NumericTextBox, FormValidator, TextBox, ColorPicker as ColorPicker$1 } from '@syncfusion/ej2-inputs';
import { CheckBox, Button, RadioButton } from '@syncfusion/ej2-buttons';
import { DropDownList, ComboBox, AutoComplete } from '@syncfusion/ej2-dropdowns';
import { ListView } from '@syncfusion/ej2-lists';
import { DropDownButton, SplitButton } from '@syncfusion/ej2-splitbuttons';
import { beforeFltrcMenuOpen, filterCmenuSelect, filterCboxValue, filterDialogCreated, filterDialogClose, fltrPrevent, customFilterOpen, parentsUntil, toogleCheckbox, createCboxWithWrap, getUid, ExcelFilterBase, CheckBoxFilterBase } from '@syncfusion/ej2-grids';
import { Chart as Chart$1, ColumnSeries, LineSeries, BarSeries, AreaSeries, StackingColumnSeries, StackingLineSeries, StackingBarSeries, ScatterSeries, StackingAreaSeries, Category, Legend, Tooltip as Tooltip$1, DataLabel, DateTime, AccumulationChart, PieSeries, AccumulationTooltip, AccumulationDataLabel, AccumulationLegend } from '@syncfusion/ej2-charts';
/**
* To get range indexes.
*
* @param {string} range - Specifies the range.
* @param {Workbook} [context] - Optional Workbook context to derive sheet information, used when the sheet name or index is provided.
* @param {number} [sheetIndex] - Optional sheet index to resolve sheet-specific range when context is provided.
* @returns {number[]} - To get range indexes.
*/
function getRangeIndexes(range, context, sheetIndex) {
let cellindexes;
const indexes = [];
if (range) {
let sheet;
if (context && !isNullOrUndefined(sheetIndex)) {
sheet = getSheet(context, sheetIndex);
}
range = range.lastIndexOf('!') > -1 ? range.substring(range.lastIndexOf('!') + 1) : range;
range = range.indexOf(':') === -1 ? range + ':' + range : range;
const containsAlphabetsAndDigits = new RegExp(/^(?=.*[a-zA-Z])(?=.*\d)/g);
if (!containsAlphabetsAndDigits.test(range)) {
const refArr = range.split(':');
range = isNullOrUndefined(range.match(/[0-9]/)) ? (refArr[0] + '1:' + refArr[1] + (sheet ? (sheet.rowCount - 1) : '1')) :
('A' + refArr[0] + ':' + (sheet ? getColumnHeaderText(sheet.colCount) : 'A') + refArr[1]);
}
range.split(':').forEach((address) => {
cellindexes = getCellIndexes(address);
indexes.push(cellindexes[0]);
indexes.push(cellindexes[1]);
});
}
return indexes;
}
/**
* To get single cell indexes
*
* @param {string} address - Specifies the address.
* @returns {number[]} - To get single cell indexes
*/
function getCellIndexes(address) {
return [parseInt(address.match(/\d+/)[0], 10) - 1, getColIndex(address.match(/[A-Z]+/i)[0].toUpperCase())];
}
/**
* To get column index from text.
*
* @hidden
* @param {string} text - Specifies the text.
* @returns {number} - To get column index from text.
*/
function getColIndex(text) {
let colIdx = 0;
text = text.split('').reverse().join('');
for (let i = text.length - 1; i >= 0; i--) {
colIdx += (text[i].charCodeAt(0) - 64) * (Math.pow(26, i));
}
return colIdx - 1;
}
/**
* To get cell address from given row and column index.
*
* @param {number} sRow - Specifies the row.
* @param {number} sCol - Specifies the col.
* @returns {string} - To get cell address from given row and column index.
*/
function getCellAddress(sRow, sCol) {
return getColumnHeaderText(sCol + 1) + (sRow + 1);
}
/**
* To get range address from given range indexes.
*
* @param {number[]} range - Specifies the range.
* @returns {string} - To get range address from given range indexes.
*/
function getRangeAddress(range) {
return getCellAddress(range[0], range[1]) + ':' + (!isNullOrUndefined(range[2]) ?
getCellAddress(range[2], range[3]) : getCellAddress(range[0], range[1]));
}
/**
* To get column header cell text
*
* @param {number} colIndex - Specifies the colIndex.
* @returns {string} - Get Column Header Text
*/
function getColumnHeaderText(colIndex) {
const alphabet = 'Z';
if (colIndex / 26 > 1) {
return getColumnHeaderText((colIndex % 26 === 0) ? (colIndex / 26 - 1) : Math.floor(colIndex / 26))
+ String.fromCharCode((colIndex % 26) === 0 ? alphabet.charCodeAt(0) : 64 + (colIndex % 26));
}
else {
return String.fromCharCode(64 + (colIndex));
}
}
/**
* @hidden
* @param {SheetModel} address - Specifies the address.
* @param {Workbook} [context] - Optional Workbook context to derive sheet information, used when the sheet name or index is provided.
* @param {number} [sheetIndex] - Optional sheet index to resolve sheet-specific range when context is provided.
* @returns {number[]} - Get Indexes From Address
*/
function getIndexesFromAddress(address, context, sheetIndex) {
return getRangeIndexes(getRangeFromAddress(address), context, sheetIndex);
}
/**
* @hidden
* @param {SheetModel} address - Specifies the address.
* @returns {string} - Get Range From Address.
*/
function getRangeFromAddress(address) {
const sheetRefIndex = address.lastIndexOf('!');
return sheetRefIndex > -1 ? address.substring(sheetRefIndex + 1) : address;
}
/**
* Get complete address for selected range
*
* @hidden
* @param {SheetModel} sheet - Specifies the sheet.
* @returns {string} - Get complete address for selected range
*/
function getAddressFromSelectedRange(sheet) {
return sheet.name + '!' + sheet.selectedRange;
}
/**
* @param {Workbook} context - Specifies the context.
* @param {string} address - Specifies the address.
* @returns {Object} - To get Address Info
* @hidden
*/
function getAddressInfo(context, address) {
const sheetIndex = getSheetIndexFromAddress(context, address);
return { sheetIndex: sheetIndex, indices: getIndexesFromAddress(address, context, sheetIndex) };
}
/**
* @param {Workbook} context - Specifies the context.
* @param {string} address - Specifies the address.
* @returns {number} - return the sheet index.
* @hidden
*/
function getSheetIndexFromAddress(context, address) {
let sIdx;
if (address.indexOf('!') > -1) {
sIdx = getSheetIndex(context, getSheetNameFromAddress(address));
}
else {
sIdx = context.activeSheetIndex;
}
return sIdx;
}
/**
* Given range will be swapped/arranged in increasing order.
*
* @hidden
* @param {number[]} range - Specifies the range.
* @returns {number[]} - Returns the bool value.
*/
function getSwapRange(range) {
const clonedRange = range.slice();
if (range[0] > range[2]) {
swap(clonedRange, 0, 2);
}
if (range[1] > range[3]) {
swap(clonedRange, 1, 3);
}
return clonedRange;
}
/**
* Interchange values in an array
*
* @param {number[]} range - Specifies the range.
* @param {number} x - Specifies the x.
* @param {number} y - Specifies the y.
* @returns {void} - Interchange values in an array.
*/
function swap(range, x, y) {
const tmp = range[x];
range[x] = range[y];
range[y] = tmp;
}
/**
* @hidden
* @param {number[]} range - Specifies the range.
* @returns {boolean} - Returns the bool value.
*/
function isSingleCell(range) {
return range[0] === range[2] && range[1] === range[3];
}
/**
* Worker task.
*
* @param {Object} context - Specify the context.
* @param {Function | Object} taskFn - Specify the task.
* @param {Function} callbackFn - Specify the callbackFn.
* @param {Object[]} data - Specify the data.
* @param {boolean} preventCallback - Specify the preventCallback.
* @param {Workbook} parent - Specify the Workbook instance.
* @returns {WorkerHelper} - Worker task.
*/
function executeTaskAsync(context, taskFn, callbackFn, data, preventCallback, parent) {
return new WorkerHelper(context, taskFn, callbackFn, data, preventCallback, parent);
}
/**
* @hidden
*
* The `WorkerHelper` module is used to perform multiple actions using Web Worker asynchronously.
*/
class WorkerHelper {
/**
* Constructor for WorkerHelper module in Workbook library.
*
* @private
* @param {Object} context - Specify the context.
* @param {Function | Object} task - Specify the task.
* @param {Function} defaultListener - Specify the defaultListener.
* @param {Object[]} taskData - Specify the taskData.
* @param {boolean} preventCallback - Specify the preventCallback.
* @param {Workbook} parent - Specify the Workbook instance.
*/
constructor(context, task, defaultListener, taskData, preventCallback, parent) {
this.preventCallback = false;
this.context = context;
this.workerTask = task;
this.defaultListener = defaultListener;
this.workerData = taskData;
this.parent = parent;
if (preventCallback) {
this.preventCallback = true;
}
this.initWorker();
}
/**
* To terminate the worker task.
*
* @private
* @returns {void} - To terminate the worker task.
*/
terminate() {
this.worker.terminate();
URL.revokeObjectURL(this.workerUrl);
}
/**
* To initiate the worker.
*
* @private
* @returns {void} - To initiate the worker.
*/
initWorker() {
const taskBlob = new Blob([this.getFnCode()], { type: 'text/javascript' });
this.workerUrl = URL.createObjectURL(taskBlob);
this.worker = new Worker(this.workerUrl);
this.worker.onmessage = this.messageFromWorker.bind(this);
this.worker.onerror = this.onError.bind(this);
if (!this.parent.isVue) {
this.worker.postMessage(this.workerData);
}
else {
const clonedData = JSON.parse(JSON.stringify(this.workerData));
this.worker.postMessage(clonedData);
}
}
/**
* Method for getting response from worker.
*
* @param {MessageEvent} args - Specify the args.
* @returns {void} - Method for getting response from worker.
* @private
*/
messageFromWorker(args) {
this.terminate();
this.defaultListener.apply(this.context, [args.data]);
}
/**
* Method for getting error message from worker if failed.
*
* @param {ErrorEvent} args - Specify the args.
* @returns {void} - Method for getting error message from worker if failed.
* @private
*/
onError(args) {
this.terminate();
if (args.message && args.message.includes('FormData')) {
this.defaultListener.apply(this.context, [{ isFormDataError: true }]);
}
else {
throw args.message || args;
}
}
/**
* Construct function code for worker.
*
* @private
* @returns {string} - Construct function code for worker.
*/
getFnCode() {
let workerCode = '';
let i;
let keys;
let workerFunction = '';
let isHaveFunction = false;
if (typeof this.workerTask === 'function') {
if (this.workerTask.toString().indexOf('function') < 0) {
workerFunction = 'function ' + this.workerTask.toString();
}
else {
workerFunction = this.workerTask.toString();
isHaveFunction = true;
}
workerCode += ('self.workerTask = ' + workerFunction + '; \n');
}
else {
if (typeof this.workerTask === 'object') {
keys = Object.keys(this.workerTask);
for (i = 0; i < keys.length; i++) {
if (this.workerTask[keys[i]].toString().indexOf('function') < 0) {
workerFunction = 'function ' + this.workerTask[keys[i]].toString();
}
else {
workerFunction = this.workerTask[keys[i]].toString();
isHaveFunction = true;
}
workerCode += ((i === 0 ? 'self.workerTask' : keys[i]) + '= ' + workerFunction + '; \n');
}
}
}
workerCode += 'self.onmessage = ' + (isHaveFunction ? '' : ' function ') +
(this.preventCallback ? this.getMessageFn.toString() : this.getCallbackMessageFn.toString()) + '; \n';
return workerCode;
}
/**
* Get default worker task with callback.
*
* @private
* @param {MessageEvent} args - Specify the args.
* @returns {void} - Get default worker task without callback.
*/
getCallbackMessageFn(args) {
postMessage(this.workerTask(...args.data));
}
/**
* Get default worker task without callback.
*
* @private
* @param {MessageEvent} args - Specify the args.
* @returns {void} - Get default worker task without callback.
*/
getMessageFn(args) {
this.workerTask(...args.data);
}
}
/**
* To get Workbook required modules.
*
* @hidden
* @param {Workbook} context - Specifies the context.
* @param {ModuleDeclaration[]} modules - Specifies the modules.
* @returns {ModuleDeclaration[]} - To get Workbook required modules.
*/
function getWorkbookRequiredModules(context, modules = []) {
modules.push({
member: 'dataBind',
args: [context]
});
modules.push({
member: 'workbookProtectSheet',
args: [context]
});
if (context.allowSave) {
modules.push({
member: 'workbookSave',
args: [context]
});
}
if (context.allowPrint) {
modules.push({
member: 'print',
args: [context]
});
}
if (context.allowOpen) {
modules.push({
member: 'workbookOpen',
args: [context]
});
}
if (context.allowEditing) {
modules.push({
member: 'workbookEdit',
args: [context]
});
modules.push({
member: 'workbookFormula',
args: [context]
});
}
if (context.allowNumberFormatting) {
modules.push({
member: 'workbookNumberFormat',
args: [context]
});
}
if (context.allowCellFormatting) {
modules.push({
member: 'workbookcellformat',
args: [context]
});
}
if (context.allowSorting) {
modules.push({ member: 'workbookSort', args: [context] });
}
if (context.allowHyperlink) {
modules.push({ member: 'workbookHyperlink', args: [context] });
}
if (context.allowFiltering) {
modules.push({ member: 'workbookFilter', args: [context] });
}
if (context.allowFindAndReplace) {
modules.push({ member: 'workbookfindAndReplace', args: [context] });
}
if (context.allowInsert) {
modules.push({ member: 'workbookinsert', args: [context] });
}
if (context.allowDelete) {
modules.push({ member: 'workbookdelete', args: [context] });
}
if (context.allowDataValidation) {
modules.push({ member: 'workbookDataValidation', args: [context] });
}
if (context.allowMerge) {
modules.push({ member: 'workbookmerge', args: [context] });
}
if (context.allowCellFormatting) {
modules.push({ member: 'workbookConditionalFormatting', args: [context] });
}
if (context.allowImage) {
modules.push({ member: 'workbookImage', args: [context] });
}
if (context.allowChart) {
modules.push({ member: 'workbookChart', args: [context] });
}
if (context.allowAutoFill) {
modules.push({ member: 'workbookautofill', args: [context] });
}
return modules;
}
var __decorate = (undefined && undefined.__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;
};
/**
* Represents the cell style.
*/
class CellStyle extends ChildProperty {
}
__decorate([
Property('Calibri')
], CellStyle.prototype, "fontFamily", void 0);
__decorate([
Property('bottom')
], CellStyle.prototype, "verticalAlign", void 0);
__decorate([
Property('left')
], CellStyle.prototype, "textAlign", void 0);
__decorate([
Property('0pt')
], CellStyle.prototype, "textIndent", void 0);
__decorate([
Property('#000000')
], CellStyle.prototype, "color", void 0);
__decorate([
Property('#ffffff')
], CellStyle.prototype, "backgroundColor", void 0);
__decorate([
Property('normal')
], CellStyle.prototype, "fontWeight", void 0);
__decorate([
Property('normal')
], CellStyle.prototype, "fontStyle", void 0);
__decorate([
Property('11pt')
], CellStyle.prototype, "fontSize", void 0);
__decorate([
Property('none')
], CellStyle.prototype, "textDecoration", void 0);
__decorate([
Property('')
], CellStyle.prototype, "border", void 0);
__decorate([
Property('')
], CellStyle.prototype, "borderTop", void 0);
__decorate([
Property('')
], CellStyle.prototype, "borderBottom", void 0);
__decorate([
Property('')
], CellStyle.prototype, "borderLeft", void 0);
__decorate([
Property('')
], CellStyle.prototype, "borderRight", void 0);
/**
* Represents the Filter Collection.
*
*/
class FilterCollection extends ChildProperty {
}
__decorate([
Property()
], FilterCollection.prototype, "sheetIndex", void 0);
__decorate([
Property()
], FilterCollection.prototype, "filterRange", void 0);
__decorate([
Property(false)
], FilterCollection.prototype, "hasFilter", void 0);
__decorate([
Property()
], FilterCollection.prototype, "column", void 0);
__decorate([
Property()
], FilterCollection.prototype, "criteria", void 0);
__decorate([
Property()
], FilterCollection.prototype, "value", void 0);
__decorate([
Property()
], FilterCollection.prototype, "dataType", void 0);
__decorate([
Property()
], FilterCollection.prototype, "predicates", void 0);
/**
* Represents the sort Collection.
*
*/
class SortCollection extends ChildProperty {
}
__decorate([
Property()
], SortCollection.prototype, "sortRange", void 0);
__decorate([
Property()
], SortCollection.prototype, "columnIndex", void 0);
__decorate([
Property()
], SortCollection.prototype, "order", void 0);
__decorate([
Property()
], SortCollection.prototype, "sheetIndex", void 0);
/**
* Represents a defined name in the spreadsheet.
* A defined name is a meaningful identifier that refers to a specific cell or range, and can be used in formulas.
*/
class DefineName extends ChildProperty {
}
__decorate([
Property('')
], DefineName.prototype, "name", void 0);
__decorate([
Property('')
], DefineName.prototype, "scope", void 0);
__decorate([
Property('')
], DefineName.prototype, "comment", void 0);
__decorate([
Property('')
], DefineName.prototype, "refersTo", void 0);
/**
* Configures the Protect behavior for the spreadsheet.
*
*/
class ProtectSettings extends ChildProperty {
}
__decorate([
Property(false)
], ProtectSettings.prototype, "selectCells", void 0);
__decorate([
Property(false)
], ProtectSettings.prototype, "selectUnLockedCells", void 0);
__decorate([
Property(false)
], ProtectSettings.prototype, "formatCells", void 0);
__decorate([
Property(false)
], ProtectSettings.prototype, "formatRows", void 0);
__decorate([
Property(false)
], ProtectSettings.prototype, "formatColumns", void 0);
__decorate([
Property(false)
], ProtectSettings.prototype, "insertLink", void 0);
/**
* Represents the Hyperlink.
*
*/
class Hyperlink extends ChildProperty {
}
__decorate([
Property('')
], Hyperlink.prototype, "address", void 0);
/**
* Represents the DataValidation.
*/
class Validation extends ChildProperty {
}
__decorate([
Property('WholeNumber')
], Validation.prototype, "type", void 0);
__decorate([
Property('Between')
], Validation.prototype, "operator", void 0);
__decorate([
Property('0')
], Validation.prototype, "value1", void 0);
__decorate([
Property('0')
], Validation.prototype, "value2", void 0);
__decorate([
Property(true)
], Validation.prototype, "ignoreBlank", void 0);
__decorate([
Property(true)
], Validation.prototype, "inCellDropDown", void 0);
__decorate([
Property(false)
], Validation.prototype, "isHighlighted", void 0);
__decorate([
Property('')
], Validation.prototype, "address", void 0);
/**
* Represents the Format.
*/
class Format extends ChildProperty {
}
__decorate([
Property('General')
], Format.prototype, "format", void 0);
__decorate([
Complex({}, CellStyle)
], Format.prototype, "style", void 0);
__decorate([
Property(true)
], Format.prototype, "isLocked", void 0);
/**
* Represents the Conditional Formatting.
*
*/
class ConditionalFormat extends ChildProperty {
}
__decorate([
Property('GreaterThan')
], ConditionalFormat.prototype, "type", void 0);
__decorate([
Complex({}, Format)
], ConditionalFormat.prototype, "format", void 0);
__decorate([
Property('RedFT')
], ConditionalFormat.prototype, "cFColor", void 0);
__decorate([
Property('')
], ConditionalFormat.prototype, "value", void 0);
__decorate([
Property('')
], ConditionalFormat.prototype, "range", void 0);
__decorate([
Property('')
], ConditionalFormat.prototype, "action", void 0);
/**
* Represents the Legend.
*
*/
class LegendSettings extends ChildProperty {
}
__decorate([
Property(true)
], LegendSettings.prototype, "visible", void 0);
__decorate([
Property('Auto')
], LegendSettings.prototype, "position", void 0);
/**
* Represents the DataLabelSettings.
*
*/
class DataLabelSettings extends ChildProperty {
}
__decorate([
Property(false)
], DataLabelSettings.prototype, "visible", void 0);
__decorate([
Property('Auto')
], DataLabelSettings.prototype, "position", void 0);
/**
* Represents the Border.
*
*/
class Border extends ChildProperty {
}
__decorate([
Property('')
], Border.prototype, "color", void 0);
__decorate([
Property(1)
], Border.prototype, "width", void 0);
/**
* Represents the MarkerSettings.
*
*/
class MarkerSettings extends ChildProperty {
}
__decorate([
Property(false)
], MarkerSettings.prototype, "visible", void 0);
__decorate([
Property('Circle')
], MarkerSettings.prototype, "shape", void 0);
__decorate([
Property(5)
], MarkerSettings.prototype, "size", void 0);
__decorate([
Property(null)
], MarkerSettings.prototype, "fill", void 0);
__decorate([
Property(true)
], MarkerSettings.prototype, "isFilled", void 0);
__decorate([
Complex({}, Border)
], MarkerSettings.prototype, "border", void 0);
/**
* Specifies the major grid lines in the `axis`.
*
*/
class MajorGridLines extends ChildProperty {
}
__decorate([
Property(0)
], MajorGridLines.prototype, "width", void 0);
/**
* Specifies the minor grid lines in the `axis`.
*
*/
class MinorGridLines extends ChildProperty {
}
__decorate([
Property(0)
], MinorGridLines.prototype, "width", void 0);
/**
* Represents the axis.
*
*/
class Axis extends ChildProperty {
}
__decorate([
Property('')
], Axis.prototype, "title", void 0);
__decorate([
Complex({}, MajorGridLines)
], Axis.prototype, "majorGridLines", void 0);
__decorate([
Complex({}, MinorGridLines)
], Axis.prototype, "minorGridLines", void 0);
__decorate([
Property(true)
], Axis.prototype, "visible", void 0);
/**
* Represents the Chart.
*/
class Chart extends ChildProperty {
}
__decorate([
Property('Line')
], Chart.prototype, "type", void 0);
__decorate([
Property('Material')
], Chart.prototype, "theme", void 0);
__decorate([
Property(false)
], Chart.prototype, "isSeriesInRows", void 0);
__decorate([
Complex({}, MarkerSettings)
], Chart.prototype, "markerSettings", void 0);
__decorate([
Property('')
], Chart.prototype, "range", void 0);
__decorate([
Property('')
], Chart.prototype, "id", void 0);
__decorate([
Property('')
], Chart.prototype, "title", void 0);
__decorate([
Property(290)
], Chart.prototype, "height", void 0);
__decorate([
Property(480)
], Chart.prototype, "width", void 0);
__decorate([
Property(0)
], Chart.prototype, "top", void 0);
__decorate([
Property(0)
], Chart.prototype, "left", void 0);
__decorate([
Complex({}, LegendSettings)
], Chart.prototype, "legendSettings", void 0);
__decorate([
Complex({}, Axis)
], Chart.prototype, "primaryXAxis", void 0);
__decorate([
Complex({}, Axis)
], Chart.prototype, "primaryYAxis", void 0);
__decorate([
Complex({}, DataLabelSettings)
], Chart.prototype, "dataLabelSettings", void 0);
/**
* Represents the Image.
*/
class Image$1 extends ChildProperty {
}
__decorate([
Property('')
], Image$1.prototype, "src", void 0);
__decorate([
Property('')
], Image$1.prototype, "id", void 0);
__decorate([
Property(300)
], Image$1.prototype, "height", void 0);
__decorate([
Property(400)
], Image$1.prototype, "width", void 0);
__decorate([
Property(0)
], Image$1.prototype, "top", void 0);
__decorate([
Property(0)
], Image$1.prototype, "left", void 0);
/**
* Represents the AutoFillSettings.
*/
class AutoFillSettings extends ChildProperty {
}
__decorate([
Property('FillSeries')
], AutoFillSettings.prototype, "fillType", void 0);
__decorate([
Property(true)
], AutoFillSettings.prototype, "showFillOptions", void 0);
/**
* Specifies Workbook internal events.
*/
/** @hidden */
const workbookDestroyed = 'workbookDestroyed';
/** @hidden */
const updateSheetFromDataSource = 'updateSheetFromDataSource';
/** @hidden */
const dataSourceChanged = 'dataSourceChanged';
/** @hidden */
const dataChanged = 'dataChanged';
/** @hidden */
const triggerDataChange = 'triggerDataChange';
/** @hidden */
const workbookOpen = 'workbookOpen';
/** @hidden */
const beginSave = 'beginSave';
/** @hidden */
const beginAction = 'actionBegin';
/** @hidden */
const sortImport = 'sortImport';
/** @hidden */
const findToolDlg = 'findToolDlg';
/** @hidden */
const exportDialog = 'exportDialog';
/** @hidden */
const setFilteredCollection = 'setFilteredCollection';
/** @hidden */
const saveCompleted = 'saveCompleted';
/** @hidden */
const applyNumberFormatting = 'applyNumber';
/** @hidden */
const getFormattedCellObject = 'getFormattedCell';
/** @hidden */
const calculateFormula = 'calculateFormula';
/** @hidden */
const refreshCellElement = 'refreshCellElem';
/** @hidden */
const setCellFormat = 'setCellFormat';
/** @hidden */
const findAllValues = 'findAllValues';
/** @hidden */
const textDecorationUpdate = 'textDecorationUpdate';
/** @hidden */
const applyCellFormat = 'applyCellFormat';
/** @hidden */
const updateUsedRange = 'updateUsedRange';
/** @hidden */
const updateRowColCount = 'updateRowColCount';
/** @hidden */
const workbookFormulaOperation = 'workbookFormulaOperation';
/** @hidden */
const workbookEditOperation = 'workbookEditOperation';
/** @hidden */
const checkDateFormat = 'checkDateFormat';
/** @hidden */
const checkNumberFormat = 'checkNumberFormat';
/** @hidden */
const parseDecimalNumber = 'parseDecimalNumber';
/** @hidden */
const getFormattedBarText = 'getFormattedBarText';
/** @hidden */
const activeCellChanged = 'activeCellChanged';
/** @hidden */
const openSuccess = 'openSuccess';
/** @hidden */
const openFailure = 'openFailure';
/** @hidden */
const sheetCreated = 'sheetCreated';
/** @hidden */
const sheetsDestroyed = 'sheetsDestroyed';
/** @hidden */
const aggregateComputation = 'aggregateComputation';
/** @hidden */
const getUniqueRange = 'getUniqueRange';
/** @hidden */
const removeUniquecol = 'removeUniquecol';
/** @hidden */
const checkUniqueRange = 'checkUniqueRange';
/** @hidden */
const reApplyFormula = 'reApplyFormula';
/** @hidden */
const clearFormulaDependentCells = 'clearFormulaDependentCells';
/** @hidden */
const formulaInValidation = 'formulaInValidation';
/** @hidden */
const beforeSort = 'beforeSort';
/** @hidden */
const initiateSort = 'initiateSort';
/** @hidden */
const updateSortedDataOnCell = 'updateSortedDataOnCell';
/** @hidden */
const sortComplete = 'sortComplete';
/** @hidden */
const sortRangeAlert = 'sortRangeAlert';
/** @hidden */
const initiatelink = 'initiatelink';
/** @hidden */
const beforeHyperlinkCreate = 'beforeHyperlinkCreate';
/** @hidden */
const afterHyperlinkCreate = 'afterHyperlinkCreate';
/** @hidden */
const beforeHyperlinkClick = 'beforeHyperlinkClick';
/** @hidden */
const afterHyperlinkClick = 'afterHyperlinkClick';
/** @hidden */
const addHyperlink = 'addHyperlink';
/** @hidden */
const setLinkModel = 'setLinkModel';
/** @hidden */
const beforeFilter = 'beforeFilter';
/** @hidden */
const initiateFilter = 'initiateFilter';
/** @hidden */
const filterComplete = 'filterComplete';
/** @hidden */
const filterRangeAlert = 'filterRangeAlert';
/** @hidden */
const clearAllFilter = 'clearAllFilter';
/** @hidden */
const wrapEvent = 'wrapText';
/** @hidden */
const onSave = 'onSave';
/** @hidden */
const insert = 'insert';
/** @hidden */
const deleteAction = 'delete';
/** @hidden */
const insertModel = 'insertModel';
/** @hidden */
const deleteModel = 'deleteModel';
/** @hidden */
const isValidation = 'isValidation';
/** @hidden */
const cellValidation = 'cellValidation';
/** @hidden */
const addHighlight = 'addHighlight';
/** @hidden */
const dataValidate = 'dataValidate';
/** @hidden */
const find = 'find';
/** @hidden */
const goto = 'gotoHandler';
/** @hidden */
const findWorkbookHandler = 'findHandler';
/** @hidden */
const replace = 'replace';
/** @hidden */
const replaceAll = 'replaceAll';
/** @hidden */
const showFindAlert = 'showFindAlert';
/** @hidden */
const findKeyUp = 'findKeyUp';
/** @hidden */
const removeHighlight = 'removeHighlight';
/** @hidden */
const queryCellInfo = 'queryCellInfo';
/** @hidden */
const count = 'count';
/** @hidden */
const findCount = 'findCount';
/** @hidden */
const protectSheetWorkBook = 'protectSheet';
/** @hidden */
const updateToggle = 'updateToggleItem';
/** @hidden */
const protectsheetHandler = 'protectsheetHandler';
/** @hidden */
const replaceAllDialog = 'replaceAllDialog';
/** @hidden */
const unprotectsheetHandler = 'unprotectsheetHandler';
/** @hidden */
const workBookeditAlert = 'editAlert';
/** @hidden */
const workbookReadonlyAlert = 'readonlyAlert';
/** @hidden */
const setLockCells = 'setLockCells';
/** @hidden */
const applyLockCells = 'applyLockCells';
/** @hidden */
const setMerge = 'setMerge';
/** @hidden */
const applyMerge = 'applyMerge';
/** @hidden */
const mergedRange = 'mergedRange';
/** @hidden */
const activeCellMergedRange = 'activeCellMergedRange';
/** @hidden */
const insertMerge = 'insertMerge';
/** @hidden */
const hideShow = 'hideShow';
/** @hidden */
const setCFRule = 'setCFRule';
/** @hidden */
const applyCF = 'applyCF';
/** @hidden */
const clearCFRule = 'clearCFRule';
/** @hidden */
const clear = 'clear';
/** @hidden */
const clearCF = 'clearCF';
/** @hidden */
const setImage = 'setImage';
/** @hidden */
const setChart = 'setChart';
/** @hidden */
const initiateChart = 'initiateChart';
/** @hidden */
const refreshRibbonIcons = 'refreshRibbonIcons';
/** @hidden */
const refreshChart = 'refreshChart';
/** @hidden */
const refreshChartSize = 'refreshChartSize';
/** @hidden */
const deleteChartColl = 'deleteChartColl';
/** @hidden */
const initiateChartModel = 'initiateChartModel';
/** @hidden */
const focusChartBorder = 'focusChartBorder';
/** @hidden */
const saveError = 'saveError';
/** @hidden */
const updateHighlight = 'updateHighlight';
/** @hidden */
const beforeInsert = 'beforeInsert';
/** @hidden */
const beforeDelete = 'beforeDelete';
/** @hidden */
const deleteHyperlink = 'deleteHyperlink';
/** @hidden */
const moveOrDuplicateSheet = 'moveOrDuplicateSheet';
/** @hidden */
const setAutoFill = 'setAutoFill';
/** @hidden */
const refreshCell = 'refreshCell';
/** @hidden */
const getFillInfo = 'getFillInfo';
/** @hidden */
const getautofillDDB = 'getautofillDDB';
/** @hidden */
const rowFillHandler = 'rowFillHandler';
/** @hidden */
const getTextSpace = 'getTextSpace';
/** @hidden */
const refreshClipboard = 'refreshClipboard';
/** @hidden */
const updateView = 'updateView';
/** @hidden */
const selectionComplete = 'selectionComplete';
/** @hidden */
const refreshInsertDelete = 'refreshInsertDelete';
/** @hidden */
const getUpdatedFormulaOnInsertDelete = 'getUpdatedFormulaOnInsertDelete';
/** @hidden */
const beforeCellUpdate = 'beforeCellUpdate';
/** @hidden */
const duplicateSheetFilterHandler = 'duplicateSheetFilterHandler';
/** @hidden */
const unMerge = 'unMerge';
/** @hidden */
const checkFormulaRef = 'checkFormulaRef';
/** @hidden */
const parseFormulaArgument = 'parseFormulaArgument';
/** @hidden */
const getCellRefValue = 'getCellRefValue';
/** @hidden */
const commputeFormulaValue = 'commputeFormulaValue';
/** @hidden */
const getChartRowIdxFromClientY = 'getChartRowIdxFromClientY';
/** @hidden */
const getChartColIdxFromClientX = 'getChartColIdxFromClientX';
/** @hidden */
const refreshChartCellOnInit = 'refreshChartCellOnInit';
/** @hidden */
const localizedFormatAction = 'localizedFormatAction';
/** @hidden */
const moveSheetHandler = 'moveSheetHandler';
/** @hidden */
const addListValidationDropdown = 'addListValidationDropdown';
/** @hidden */
const sheetRenameUpdate = 'sheetRenameUpdate';
/** @hidden */
const updateSortCollection = 'updateSortCollection';
/** @hidden */
const importModelUpdate = 'importModelUpdate';
/**
* Check the value of the cell is number with thousand separator and currency symbol and returns the parsed value.
*
* @param {CellModel} cell - Specifies the cell.
* @param {string} locale - Specifies the locale.
* @param {string} groupSep - Specifies the group separator.
* @param {string} decimalSep - Specifies the decimal separator.
* @param {string} currencySym - Specifies the currency Symbol.
* @param {boolean} isFractionalType - Defines whether the value is a fractional type or not.
* @param {boolean} checkCurrency - Specifies the currency check.
* @returns {Object} - returns the parsed value.
* @hidden
*/
function checkIsNumberAndGetNumber(cell, locale, groupSep, decimalSep, currencySym, isFractionalType, checkCurrency) {
let cellValue = cell.value;
if (cellValue && typeof cellValue === 'string') {
if (cellValue.includes('\n')) {
return { isNumber: false, value: cellValue };
}
if (isNumber(cellValue)) {
return { isNumber: true, value: cellValue };
}
if (currencySym && cellValue.includes(currencySym) && (checkCurrency || cell.format.includes(currencySym) || cell.format.includes('$'))) {
cellValue = cellValue.replace(currencySym, '').trim();
}
if (groupSep && cellValue.includes(groupSep) && parseThousandSeparator(cellValue, locale, groupSep, decimalSep)) {
cellValue = cellValue.split(groupSep).join('').trim();
}
if (!decimalSep) {
decimalSep = getNumericObject(locale).decimal;
}
if (decimalSep !== '.' && cellValue.includes(decimalSep)) {
cellValue = cellValue.replace(decimalSep, '.').trim();
}
if (isNumber(cellValue)) {
return { isNumber: true, value: cellValue };
}
if (isFractionalType && cellValue.split('/').length === 2) {
try {
const splittedVal = cellValue.split(' ');
if (splittedVal.length === 2 && splittedVal[0].split('/').length === 1) {
const result = evaluate(splittedVal[0]);
const result1 = evaluate(splittedVal[1]);
cellValue = result + result1;
}
else {
cellValue = evaluate(cellValue);
}
return { isNumber: true, value: cellValue };
}
catch (error) {
return { isNumber: false, value: cellValue };
}
}
}
else if (isNumber(cellValue)) {
return { isNumber: true, value: cellValue };
}
return { isNumber: false, value: cellValue };
}
/**
* @param {string} value - Specifies the value.
* @param {string} locale - Specifies the locale.
* @param {string} groupSep - Specifies the group separator.
* @param {string} decimalSep - Specifies the decimal separator.
* @returns {boolean} - Returns parsed thousand separator.
* @hidden
*/
function parseThousandSeparator(value, locale, groupSep, decimalSep) {
let isParsed = false;
const number = 123456;
const parsedNum = number.toLocaleString(locale);
const splitedNum = parsedNum.split(groupSep).reverse();
const splitedValue = value.split(decimalSep)[0].split(groupSep);
for (let i = 0; i < splitedValue.length; i++) {
if (i === splitedValue.length - 1) {
isParsed = splitedValue[i].length === splitedNum[0].length;
}
else {
isParsed = !isUndefined$1(splitedNum[1]) && (i === 0 ? splitedValue[i].length <= splitedNum[1].length :
splitedValue[i].length === splitedNum[1].length);
}
if (!isParsed) {
break;
}
}
return isParsed;
}
/**
* Check whether the text is formula or not.
*
* @param {string} text - Specify the text.
* @param {boolean} isEditing - Specify the isEditing.
* @returns {boolean} - Check whether the text is formula or not.
*/
function checkIsFormula(text, isEditing) {
return text && text[0] === '=' && (text.length > 1 || isEditing);
}
/**
* Check whether the value is cell reference or not.
*
* @param {string} value - Specify the value to check.
* @returns {boolean} - Returns boolean value
*/
function isCellReference(value) {
let range = value;
range = range.split('$').join('');
if (range.indexOf(':') > -1) {
const rangeSplit = range.split(':');
if (isValidCellReference(rangeSplit[0]) && isValidCellReference(rangeSplit[1])) {
return true;
}
}
else if (range.indexOf(':') < 0) {
if (isValidCellReference(range)) {
return true;
}
}
return false;
}
/**
* Check whether the value is character or not.
*
* @param {string} value - Specify the value to check.
* @returns {boolean} - Returns boolean value
*/
function isChar(value) {
if ((value.charCodeAt(0) >= 65 && value.charCodeAt(0) <= 90) || (value.charCodeAt(0) >= 97 && value.charCodeAt(0) <= 122)) {
return true;
}
return false;
}
/**
* Check whether the range selection is on complete row.
*
* @param {SheetModel} sheet - Specify the sheet.
* @param {number[]} range - Specify the range index.
* @returns {boolean} - Returns boolean value
* @hidden
*/
function isRowSelected(sheet, range) {
return range[1] === 0 && range[3] === sheet.colCount - 1;
}
/**
* Check whether the range selection is on complete column.
*
* @param {SheetModel} sheet - Specify the sheet.
* @param {number[]} range - Specify the range index.
* @returns {boolean} - Returns boolean value
* @hidden
*/
function isColumnSelected(sheet, range) {
return range[0] === 0 && range[2] === sheet.rowCount - 1;
}
/**
* @param {number[]} range - Specify the range
* @param {number} rowIdx - Specify the row index
* @param {number} colIdx - Specify the col index
* @returns {boolean} - Returns boolean value
*/
function inRange(range, rowIdx, colIdx) {
return range && (rowIdx >= range[0] && rowIdx <= range[2] && colIdx >= range[1] && colIdx <= range[3]);
}
/**
* @param {number[]} address - Specify the address
* @param {number} rowIdx - Specify the row index
* @param {number} colIdx - Specify the col index
* @returns {boolean} - Returns boolean value
*/
function isInMultipleRange(address, rowIdx, colIdx) {
let range;
let isInRange;
const splitedAddress = address.split(' ');
for (let i = 0, len = splitedAddress.length; i < len; i++) {
range = getRangeIndexes(splitedAddress[i]);
isInRange = inRange(range, rowIdx, colIdx);
if (isInRange) {
break;
}
}
return isInRange;
}
/** @hidden
* @param {number[]} range - Specify the range
* @param {number[]} testRange - Specify the test range
* @param {boolean} isModify - Specify the boolean value
* @returns {boolean} - Returns boolean value
*/
function isInRange(range, testRange, isModify) {
let inRange = range[0] <= testRange[0] && range[2] >= testRange[2] && range[1] <= testRange[1] && range[3] >= testRange[3];
if (inRange) {
return true;
}
if (isModify) {
if (testRange[0] < range[0] && testRange[2] < range[0] || testRange[0] > range[2] && testRange[2] > range[2]) {
return false;
}
else {
if (testRange[0] < range[0] && testRange[2] > range[0]) {
testRange[0] = range[0];
inRange = true;
}
if (testRange[2] > range[2]) {
testRange[2] = range[2];
inRange = true;
}
}
if (testRange[1] < range[1] && testRange[3] < range[1] || testRange[1] > range[3] && testRange[3] > range[3]) {
return false;
}
else {
if (testRange[1] < range[1] && testRange[3] > range[1]) {
testRange[1] = range[1];
inRange = true;
}
if (testRange[3] > range[3]) {
testRange[3] = range[3];
inRange = true;
}
}
}
return inRange;
}
/**
* @hidden
* @param {string} address - Specifies the address for whole column.
* @param {number[]} testRange - Specifies range used to split the address.
* @param {number} colIdx - Specifies the column index.
* @returns {string} - returns the modified address.
*/
function getSplittedAddressForColumn(address, testRange, colIdx) {
const colName = getColumnHeaderText(colIdx + 1);
if (address) {
address.split(' ').forEach((addrs) => {
const range = getRangeIndexes(addrs);
if (isInRange(range, testRange)) {
address = address.split(addrs).join(colName + (range[0] + 1) +
':' + colName + testRange[0] + ' ' + colName + (testRange[2] + 2) +
':' + colName + (range[2] + 1));
}
else if (isInRange(range, testRange, true)) {
let modifiedAddress;
if (testRange[0] > range[0]) {
modifiedAddress = colName + (range[0] + 1) + ':' + colName + testRange[0];
}
else {
modifiedAddress = colName + (testRange[2] + 2) + ':' + colName + (range[2] + 1);
}
address = address.split(addrs).join(modifiedAddress);
}
});
}
else {
address = colName + '1:' + colName + testRange[0] + ' ' + colName + (testRange[2] + 2) + ':' + colName + '1048576';
}
return address;
}
/**
* Check whether the cell is locked or not
*
* @param {CellModel} cell - Specify the cell.
* @param {ColumnModel} column - Specify the column.
* @returns {boolean} - Returns boolean value
* @hidden
*/
function isLocked(cell, column) {
if (!cell) {
cell = {};
}
if (cell.isLocked) {
return true;
}
else if (cell.isLocked === false) {
return false;
}
else if (column && column.isLocked) {
return true;
}
else if (!cell.isLocked && (column && column.isLocked !== false)) {
return true;
}
return false;
}
/**
* Check whether the value is cell reference or not.
*
* @param {string} value - Specify the value to check.
* @returns {boolean} - Returns boolean value
* @hidden
*/
function isValidCellReference(value) {
const text = value;
let endNum = 0;
const textLength = text.length;
for (let i = 0; i < textLength; i++) {
if (isChar(text[i])) {
endNum++;
}
}
const cellText = text.substring(0, endNum);
const cellTextLength = cellText.length;
if (cellTextLength !== textLength) {
if (cellTextLength < 4) {
if (textLength !== 1 && (isNaN(parseInt(text, 10)))) {
const cellColIndex = columnIndex(cellText);
// XFD is the last column, 16384 - Maximum number of columns in excel.
if (cellColIndex < 1 || cellColIndex > 16384) {
return false;
}
const rowText = text.substring(endNum, textLength);
if (rowText.length > 0) {
let isNumeric = true;
for (let j = 0; j < rowText.length; j++) {
const charCode = rowText.charCodeAt(j);
if (charCode < 48 || charCode > 57) {
isNumeric = false;
break;
}
}
if (isNumeric) {
const cellNumber = parseFloat(rowText);
if (cellNumber > 0 && cellNumber < 1048577) { // 1048576 - Maximum number of rows in excel.
return true;
}
}
}
}
}
}
return false;
}
/**
* To get the column index of the given cell.
*
* @param {string} cell - Cell address for getting column index.
* @returns {number} - To get the column index of the given cell.
* @hidden
*/
function columnIndex(cell) {
let j = 0;
let k = 0;
cell = cell.toUpperCase();
if (j < cell.length && cell[j] === '!') {
j++;
while (j < cell.length && cell[j] !== '!') {
j++;
}
j++;
}
while (j < cell.length && isChar(cell[j])) {
const charCode = cell[j].charCodeAt(0);
k = k * 26 + charCode - 64;
j++;
}
if (k === 0) {
return -1;
}
return k;
}
/**
* @hidden
* @param {SheetModel} sheet - Specify the sheet
* @param {number} index - specify the index
* @param {boolean} increase - specify the boolean value.
* @param {string} layout - specify the string
* @param {number} count - specify the count.
* @returns {number} - To skip the hidden index
*
*/
function skipHiddenIdx(sheet, index, increase, layout = 'rows', count) {
let rowColObj;
if (sheet) {
if (increase) {
for (let i = index; i < Infinity; i++) {
rowColObj = sheet[`${layout}`];
if (rowColObj[index] && rowColObj[index].hidden) {
index++;
}
else {
if (count) {
count--;
index++;
}
else {
break;
}
}
}
}
else {
for (let i = index; i > -1; i--) {
rowColObj = sheet[`${layout}`];
if (rowColObj[index] && rowColObj[index].hidden) {
index--;
}
else {
break;
}
}
}
}
return index;
}
/**
* @param {CellStyleModel} style - Cell style.
* @param {boolean} onActionUpdate - Specifies the action.
* @returns {boolean} - retruns `true` is height needs to be checked.
* @hidden
*/
function isHeightCheckNeeded(style, onActionUpdate) {
const keys = Object.keys(style);
return (onActionUpdate ? keys.indexOf('fontSize') > -1 : keys.indexOf('fontSize') > -1
&& Number(style.fontSize.split('pt')[0]) > 12) || keys.indexOf('fontFamily') > -1 || keys.indexOf('borderTop') > -1
|| keys.indexOf('borderBottom') > -1;
}
/**
* Fixes row index overflow by wrapping it within the valid Excel row index range (0 to 1048575).
*
* @param {number} index - The row index to adjust.
* @returns {number} - The adjusted row index.
* @hidden
*/
function fixRowIndexOverflow(index) {
if (index > 1048575) {
return index - 1048576;
}
else if (index < 0) {
return index + 1048576;
}
return index;
}
/**
* Fixes column index overflow by wrapping it within the valid Excel column index range (0 to 16383).
*
* @param {number} index - The column index to adjust.
* @returns {number} - The adjusted column index.
* @hidden
*/
function fixColIndexOverflow(index) {
if (index > 16383) {
return index - 16384;
}
else if (index < 0) {
return index + 16384;
}
return index;
}
/**
* @param