@progress/kendo-spreadsheet-common 1.1.3-develop.1 → 1.1.3-develop.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index-esm.js +316 -103
- package/dist/index.js +316 -102
- package/package.json +1 -1
- package/src/index.d.ts +59 -1
package/dist/index-esm.js
CHANGED
|
@@ -2485,13 +2485,13 @@ function compileArgumentChecks(functionName, args) {
|
|
|
2485
2485
|
}
|
|
2486
2486
|
}
|
|
2487
2487
|
|
|
2488
|
-
function limitPrecision$1(num) {
|
|
2489
|
-
return num === parseInt(num, 10) ? num : +num.toPrecision(16);
|
|
2488
|
+
function limitPrecision$1(num, digits) {
|
|
2489
|
+
return num === parseInt(num, 10) ? num : +num.toPrecision(digits || 16);
|
|
2490
2490
|
}
|
|
2491
2491
|
|
|
2492
|
-
function maybeRoundFloatErrors(num) {
|
|
2492
|
+
function maybeRoundFloatErrors(num, digits) {
|
|
2493
2493
|
if (typeof num == "number") {
|
|
2494
|
-
return limitPrecision$1(num);
|
|
2494
|
+
return limitPrecision$1(num, digits);
|
|
2495
2495
|
} else {
|
|
2496
2496
|
return num;
|
|
2497
2497
|
}
|
|
@@ -5650,6 +5650,10 @@ class FormulaContext {
|
|
|
5650
5650
|
// try global name
|
|
5651
5651
|
val = this.workbook.nameValue(this._displayString(ref.name));
|
|
5652
5652
|
}
|
|
5653
|
+
if (val == null) {
|
|
5654
|
+
// try without _displayString
|
|
5655
|
+
val = this.workbook.nameValue(ref.print()) || this.workbook.nameValue(ref.name);
|
|
5656
|
+
}
|
|
5653
5657
|
}
|
|
5654
5658
|
if (val instanceof Ref) {
|
|
5655
5659
|
val = val.absolute(frow, fcol);
|
|
@@ -8868,6 +8872,7 @@ let Range$1 = class Range {
|
|
|
8868
8872
|
sheet._set(ref, propName, propValue);
|
|
8869
8873
|
};
|
|
8870
8874
|
|
|
8875
|
+
let isValue = false;
|
|
8871
8876
|
for (ci = topLeftCol; ci <= bottomRightCol; ci ++) {
|
|
8872
8877
|
if (!isAutofill && sheet.isHiddenColumn(ci)) {
|
|
8873
8878
|
continue;
|
|
@@ -8883,12 +8888,14 @@ let Range$1 = class Range {
|
|
|
8883
8888
|
if (row) {
|
|
8884
8889
|
data = row[ci - topLeftCol];
|
|
8885
8890
|
if (data) {
|
|
8886
|
-
Object.keys(data)
|
|
8891
|
+
const keys = Object.keys(data);
|
|
8892
|
+
keys.forEach(setProp);
|
|
8893
|
+
isValue = isValue || keys.includes("value");
|
|
8887
8894
|
}
|
|
8888
8895
|
}
|
|
8889
8896
|
}
|
|
8890
8897
|
}
|
|
8891
|
-
sheet.triggerChange({ recalc: true, ref: this._ref });
|
|
8898
|
+
sheet.triggerChange({ recalc: true, ref: this._ref, isValue: isValue });
|
|
8892
8899
|
return this;
|
|
8893
8900
|
}
|
|
8894
8901
|
}
|
|
@@ -8901,7 +8908,8 @@ let Range$1 = class Range {
|
|
|
8901
8908
|
|
|
8902
8909
|
let reason = {
|
|
8903
8910
|
recalc: clearAll || options.contentsOnly,
|
|
8904
|
-
ref: this._ref
|
|
8911
|
+
ref: this._ref,
|
|
8912
|
+
isValue: true
|
|
8905
8913
|
};
|
|
8906
8914
|
|
|
8907
8915
|
sheet.batch(function() {
|
|
@@ -16172,7 +16180,7 @@ function drawCell(collection, cell, cls, showGrid) {
|
|
|
16172
16180
|
if (data.__dataType) {
|
|
16173
16181
|
type = data.__dataType;
|
|
16174
16182
|
}
|
|
16175
|
-
} else if (data
|
|
16183
|
+
} else if (data != null) {
|
|
16176
16184
|
if (cell.html) {
|
|
16177
16185
|
data = dom.html(data);
|
|
16178
16186
|
} else {
|
|
@@ -16207,6 +16215,17 @@ function drawCell(collection, cell, cls, showGrid) {
|
|
|
16207
16215
|
}
|
|
16208
16216
|
if (cell.merged) {
|
|
16209
16217
|
classNames.push("k-spreadsheet-merged-cell");
|
|
16218
|
+
if (!cell.enable) {
|
|
16219
|
+
collection.push(dom.element("div", {
|
|
16220
|
+
className: "k-spreadsheet-disabled-mask",
|
|
16221
|
+
style: {
|
|
16222
|
+
left: (cell.left + 1) + "px",
|
|
16223
|
+
top: (cell.top + 1) + "px",
|
|
16224
|
+
width: (cell.width - 1) + "px",
|
|
16225
|
+
height: (cell.height - 1) + "px"
|
|
16226
|
+
}
|
|
16227
|
+
}));
|
|
16228
|
+
}
|
|
16210
16229
|
}
|
|
16211
16230
|
if (cell.comment) {
|
|
16212
16231
|
classNames.push("k-spreadsheet-has-comment");
|
|
@@ -17813,27 +17832,43 @@ function addCell(table, row, cell) {
|
|
|
17813
17832
|
}
|
|
17814
17833
|
}
|
|
17815
17834
|
|
|
17835
|
+
let attrs = { style: style };
|
|
17836
|
+
|
|
17816
17837
|
if (!style.textAlign) {
|
|
17817
17838
|
switch (type) {
|
|
17818
|
-
|
|
17819
|
-
|
|
17820
|
-
|
|
17821
|
-
|
|
17822
|
-
|
|
17823
|
-
|
|
17824
|
-
|
|
17825
|
-
|
|
17839
|
+
case "number":
|
|
17840
|
+
case "date":
|
|
17841
|
+
case "percent":
|
|
17842
|
+
case "currency":
|
|
17843
|
+
style.textAlign = "right";
|
|
17844
|
+
break;
|
|
17845
|
+
case "boolean":
|
|
17846
|
+
style.textAlign = "center";
|
|
17826
17847
|
break;
|
|
17827
17848
|
}
|
|
17828
17849
|
}
|
|
17829
17850
|
|
|
17851
|
+
if (!/^(?:string|undefined)$/.test(type)) {
|
|
17852
|
+
// provide original value and number format for better
|
|
17853
|
+
// interoperability with google sheets and libre office.
|
|
17854
|
+
attrs.sdval = cell.value;
|
|
17855
|
+
attrs["data-sheets-value"] = JSON.stringify({ 1: 3, 3: cell.value });
|
|
17856
|
+
if (format) {
|
|
17857
|
+
attrs.sdnum = format;
|
|
17858
|
+
attrs["data-sheets-numberformat"] = JSON.stringify({ 1: 2, 2: format, 3: 1 });
|
|
17859
|
+
}
|
|
17860
|
+
}
|
|
17861
|
+
if (cell.formula) {
|
|
17862
|
+
attrs["data-sheets-formula"] = "=" + cell.formula.print();
|
|
17863
|
+
}
|
|
17864
|
+
|
|
17830
17865
|
let className = null;
|
|
17831
17866
|
|
|
17832
17867
|
if (cell.enable === false) {
|
|
17833
17868
|
className = "k-disabled";
|
|
17834
17869
|
}
|
|
17835
17870
|
|
|
17836
|
-
let td = table.addCell(row, data,
|
|
17871
|
+
let td = table.addCell(row, data, attrs, className, cell.validation);
|
|
17837
17872
|
|
|
17838
17873
|
let border, sibling;
|
|
17839
17874
|
|
|
@@ -17892,7 +17927,7 @@ class HtmlTable {
|
|
|
17892
17927
|
this.trs.push(tr);
|
|
17893
17928
|
}
|
|
17894
17929
|
|
|
17895
|
-
addCell(rowIndex, text,
|
|
17930
|
+
addCell(rowIndex, text, attrs, className, validation) {
|
|
17896
17931
|
if (text === null || text === undefined) {
|
|
17897
17932
|
text = "";
|
|
17898
17933
|
}
|
|
@@ -17901,19 +17936,18 @@ class HtmlTable {
|
|
|
17901
17936
|
}
|
|
17902
17937
|
|
|
17903
17938
|
let children = [ text ];
|
|
17904
|
-
let properties = { style: style };
|
|
17905
17939
|
|
|
17906
17940
|
if (validation && !validation.value) {
|
|
17907
17941
|
children.push(dom.element("span", { className: "k-dirty" }));
|
|
17908
17942
|
|
|
17909
17943
|
className = (className || "") + (className ? " " : "") + "k-dirty-cell";
|
|
17910
|
-
|
|
17944
|
+
attrs.title = validation.message;
|
|
17911
17945
|
}
|
|
17912
17946
|
|
|
17913
17947
|
if (className) {
|
|
17914
|
-
|
|
17948
|
+
attrs.className = className;
|
|
17915
17949
|
}
|
|
17916
|
-
let td = dom.element("td",
|
|
17950
|
+
let td = dom.element("td", attrs, children);
|
|
17917
17951
|
|
|
17918
17952
|
this.trs[rowIndex].children.push(td);
|
|
17919
17953
|
return td;
|
|
@@ -18906,7 +18940,13 @@ function stripStyle(style) {
|
|
|
18906
18940
|
return style.replace(/^-(?:ms|moz|webkit)-/, "");
|
|
18907
18941
|
}
|
|
18908
18942
|
|
|
18909
|
-
function borderObject(styles) {
|
|
18943
|
+
function borderObject(element, styles) {
|
|
18944
|
+
// MS Office uses class name and writes borders in the <style> section, so for it we need to
|
|
18945
|
+
// use the computed styles. For Google Sheets / LibreOffice, however, the inline styles are
|
|
18946
|
+
// more accurate.
|
|
18947
|
+
if (!element.className) {
|
|
18948
|
+
styles = element.style;
|
|
18949
|
+
}
|
|
18910
18950
|
let obj = {};
|
|
18911
18951
|
[
|
|
18912
18952
|
"borderBottom",
|
|
@@ -18914,16 +18954,45 @@ function borderObject(styles) {
|
|
|
18914
18954
|
"borderLeft",
|
|
18915
18955
|
"borderTop"
|
|
18916
18956
|
].forEach(function(key) {
|
|
18917
|
-
|
|
18918
|
-
|
|
18919
|
-
|
|
18920
|
-
}
|
|
18957
|
+
let width = styles[key + "Width"];
|
|
18958
|
+
if (width) {
|
|
18959
|
+
width = parseInt(width, 10);
|
|
18960
|
+
}
|
|
18961
|
+
if (width) {
|
|
18962
|
+
obj[key] = {
|
|
18963
|
+
size: width,
|
|
18964
|
+
color: styles[key + "Color"] || "#000"
|
|
18965
|
+
};
|
|
18966
|
+
}
|
|
18921
18967
|
});
|
|
18922
18968
|
return obj;
|
|
18923
18969
|
}
|
|
18924
18970
|
|
|
18925
18971
|
function cellState(row, col, element, hBorders, vBorders) {
|
|
18926
18972
|
let styles = window.getComputedStyle(element);
|
|
18973
|
+
let value, format, formula;
|
|
18974
|
+
|
|
18975
|
+
// google sheets
|
|
18976
|
+
if ((value = element.getAttribute("data-sheets-value"))) {
|
|
18977
|
+
value = JSON.parse(value);
|
|
18978
|
+
value = value[value[1]];
|
|
18979
|
+
}
|
|
18980
|
+
if ((format = element.getAttribute("data-sheets-numberformat"))) {
|
|
18981
|
+
format = JSON.parse(format);
|
|
18982
|
+
format = format[format[1]];
|
|
18983
|
+
}
|
|
18984
|
+
formula = element.getAttribute("data-sheets-formula");
|
|
18985
|
+
|
|
18986
|
+
// libre office
|
|
18987
|
+
if (value == null && format == null && formula == null) {
|
|
18988
|
+
value = element.getAttribute("sdval");
|
|
18989
|
+
format = element.getAttribute("sdnum");
|
|
18990
|
+
if (format) {
|
|
18991
|
+
// for ungoogable reasons, libreoffice prepends format strings with
|
|
18992
|
+
// "1033;" and sometimes with "1033;0;". discard it below.
|
|
18993
|
+
format = format.replace(/^1033;(?:0;)?/, "");
|
|
18994
|
+
}
|
|
18995
|
+
}
|
|
18927
18996
|
|
|
18928
18997
|
// note: Chrome 70 appends a \t to a cell's text, which is actually mandated by the standard
|
|
18929
18998
|
// ([1] item 6). We remove it below. In [2] it's suggested they might switch back to
|
|
@@ -18931,49 +19000,62 @@ function cellState(row, col, element, hBorders, vBorders) {
|
|
|
18931
19000
|
//
|
|
18932
19001
|
// [1] https://www.w3.org/TR/html53/dom.html#dom-htmlelement-innertext
|
|
18933
19002
|
// [2] https://bugs.chromium.org/p/chromium/issues/detail?id=897373
|
|
18934
|
-
|
|
19003
|
+
if (value == null) {
|
|
19004
|
+
value = (element.innerText || element.textContent).replace(/\t$/, "");
|
|
19005
|
+
}
|
|
18935
19006
|
|
|
18936
|
-
let borders = borderObject(styles);
|
|
19007
|
+
let borders = borderObject(element, styles);
|
|
18937
19008
|
let state = {
|
|
18938
|
-
value:
|
|
19009
|
+
value: value === "" ? null : value,
|
|
19010
|
+
formula: formula,
|
|
18939
19011
|
|
|
18940
19012
|
borderTop: borders.borderTop || hBorders.get(row, col) || null,
|
|
18941
19013
|
borderBottom: borders.borderBottom || hBorders.get(row + 1, col) || null,
|
|
18942
19014
|
borderLeft: borders.borderLeft || vBorders.get(row, col) || null,
|
|
18943
19015
|
borderRight: borders.borderRight || vBorders.get(row, col + 1) || null,
|
|
18944
19016
|
|
|
18945
|
-
fontSize: parseInt(styles["
|
|
19017
|
+
fontSize: parseInt(styles["fontSize"], 10)
|
|
18946
19018
|
};
|
|
18947
19019
|
|
|
19020
|
+
if (format != null) {
|
|
19021
|
+
state.format = format;
|
|
19022
|
+
}
|
|
19023
|
+
|
|
18948
19024
|
hBorders.set(row, col, state.borderTop);
|
|
18949
19025
|
hBorders.set(row + 1, col, state.borderBottom);
|
|
18950
19026
|
vBorders.set(row, col, state.borderLeft);
|
|
18951
19027
|
vBorders.set(row, col + 1, state.borderRight);
|
|
18952
19028
|
|
|
18953
|
-
if (styles["
|
|
18954
|
-
state.background = styles["
|
|
19029
|
+
if (styles["backgroundColor"] !== "rgb(0, 0, 0)" && styles["backgroundColor"] !== "rgba(0, 0, 0, 0)") {
|
|
19030
|
+
state.background = styles["backgroundColor"];
|
|
19031
|
+
}
|
|
19032
|
+
if (stripStyle(styles["textAlign"]) !== "right") {
|
|
19033
|
+
state.textAlign = stripStyle(styles["textAlign"]);
|
|
19034
|
+
}
|
|
19035
|
+
if (styles["verticalAlign"] !== "middle") {
|
|
19036
|
+
state.verticalAlign = styles["verticalAlign"];
|
|
19037
|
+
}
|
|
19038
|
+
if (styles["wordWrap"] !== "normal" ) {
|
|
19039
|
+
state.wrap = true;
|
|
19040
|
+
}
|
|
19041
|
+
|
|
19042
|
+
const txtElem = element.querySelector("font"); // libre office
|
|
19043
|
+
if (txtElem) {
|
|
19044
|
+
styles = window.getComputedStyle(txtElem);
|
|
18955
19045
|
}
|
|
19046
|
+
|
|
18956
19047
|
if (styles.color !== "rgb(0, 0, 0)" && styles.color !== "rgba(0, 0, 0, 0)") {
|
|
18957
19048
|
state.color = styles.color;
|
|
18958
19049
|
}
|
|
18959
|
-
if (styles["
|
|
19050
|
+
if (/^underline/.test(styles["textDecoration"])) {
|
|
18960
19051
|
state.underline = true;
|
|
18961
19052
|
}
|
|
18962
|
-
if (styles["
|
|
19053
|
+
if (styles["fontStyle"] == "italic") {
|
|
18963
19054
|
state.italic = true;
|
|
18964
19055
|
}
|
|
18965
|
-
if (styles["
|
|
19056
|
+
if (/^(?:bold|[67]00)$/i.test(styles["fontWeight"])) {
|
|
18966
19057
|
state.bold = true;
|
|
18967
19058
|
}
|
|
18968
|
-
if (stripStyle(styles["text-align"]) !== "right") {
|
|
18969
|
-
state.textAlign = stripStyle(styles["text-align"]);
|
|
18970
|
-
}
|
|
18971
|
-
if (styles["vertical-align"] !== "middle") {
|
|
18972
|
-
state.verticalAlign = styles["vertical-align"];
|
|
18973
|
-
}
|
|
18974
|
-
if (styles["word-wrap"] !== "normal" ) {
|
|
18975
|
-
state.wrap = true;
|
|
18976
|
-
}
|
|
18977
19059
|
|
|
18978
19060
|
return state;
|
|
18979
19061
|
}
|
|
@@ -20807,6 +20889,60 @@ const parseXML = function parseXML() {
|
|
|
20807
20889
|
}
|
|
20808
20890
|
};
|
|
20809
20891
|
|
|
20892
|
+
class Deferred {
|
|
20893
|
+
constructor() {
|
|
20894
|
+
this._progressHandlers = [];
|
|
20895
|
+
this._resolved = false;
|
|
20896
|
+
this._rejected = false;
|
|
20897
|
+
this.promise = new window.Promise((resolve, reject) => {
|
|
20898
|
+
this._resolve = (value) => {
|
|
20899
|
+
if (!this._resolved && !this._rejected) {
|
|
20900
|
+
this._resolved = true;
|
|
20901
|
+
resolve(value);
|
|
20902
|
+
}
|
|
20903
|
+
};
|
|
20904
|
+
this._reject = (reason) => {
|
|
20905
|
+
if (!this._resolved && !this._rejected) {
|
|
20906
|
+
this._rejected = true;
|
|
20907
|
+
reject(reason);
|
|
20908
|
+
}
|
|
20909
|
+
};
|
|
20910
|
+
});
|
|
20911
|
+
}
|
|
20912
|
+
|
|
20913
|
+
resolve(value) {
|
|
20914
|
+
this._resolve(value);
|
|
20915
|
+
return this;
|
|
20916
|
+
}
|
|
20917
|
+
|
|
20918
|
+
reject(reason) {
|
|
20919
|
+
this._reject(reason);
|
|
20920
|
+
return this;
|
|
20921
|
+
}
|
|
20922
|
+
|
|
20923
|
+
notify(value) {
|
|
20924
|
+
if (!this._resolved && !this._rejected) {
|
|
20925
|
+
this._progressHandlers.forEach(handler => handler(value));
|
|
20926
|
+
}
|
|
20927
|
+
}
|
|
20928
|
+
|
|
20929
|
+
progress(callback) {
|
|
20930
|
+
this._progressHandlers.push(callback);
|
|
20931
|
+
return this;
|
|
20932
|
+
}
|
|
20933
|
+
|
|
20934
|
+
then(onFulfilled, onRejected, onProgress) {
|
|
20935
|
+
if (onProgress) {
|
|
20936
|
+
this.progress(onProgress);
|
|
20937
|
+
}
|
|
20938
|
+
return this.promise.then(onFulfilled, onRejected);
|
|
20939
|
+
}
|
|
20940
|
+
|
|
20941
|
+
promise() {
|
|
20942
|
+
return this.promise;
|
|
20943
|
+
}
|
|
20944
|
+
}
|
|
20945
|
+
|
|
20810
20946
|
/* eslint-disable complexity */
|
|
20811
20947
|
|
|
20812
20948
|
// WARNING: removing the following jshint declaration and turning
|
|
@@ -20821,12 +20957,11 @@ let MAP_EXCEL_OPERATOR = {
|
|
|
20821
20957
|
|
|
20822
20958
|
let ERROR_LOG = null;
|
|
20823
20959
|
|
|
20824
|
-
function readExcel(file, workbook) {
|
|
20960
|
+
function readExcel(file, workbook, deferred) {
|
|
20825
20961
|
let reader = new FileReader();
|
|
20826
|
-
reader.onload = function(e) {
|
|
20827
|
-
JSZip.loadAsync(e.target.result)
|
|
20828
|
-
readWorkbook(zip, workbook);
|
|
20829
|
-
});
|
|
20962
|
+
reader.onload = async function(e) {
|
|
20963
|
+
JSZip.loadAsync(e.target.result)
|
|
20964
|
+
.then(async zip => await readWorkbook(zip, workbook, deferred));
|
|
20830
20965
|
};
|
|
20831
20966
|
|
|
20832
20967
|
reader.readAsArrayBuffer(file);
|
|
@@ -20848,6 +20983,7 @@ let SEL_VALUE = ["sheetData", "row", "c", "v"];
|
|
|
20848
20983
|
let SEL_VIEW = ["bookViews", "workbookView"];
|
|
20849
20984
|
let SEL_SHEET_VIEW = ["sheetViews", "sheetView"];
|
|
20850
20985
|
let SEL_HYPERLINK = ["hyperlinks", "hyperlink"];
|
|
20986
|
+
let SEL_PROTECTION = ["sheetProtection"];
|
|
20851
20987
|
|
|
20852
20988
|
/* A validation section looks like this:
|
|
20853
20989
|
*
|
|
@@ -20909,7 +21045,7 @@ function xl(file) {
|
|
|
20909
21045
|
return file;
|
|
20910
21046
|
}
|
|
20911
21047
|
|
|
20912
|
-
async function readWorkbook(zip, workbook) {
|
|
21048
|
+
async function readWorkbook(zip, workbook, progress) {
|
|
20913
21049
|
ERROR_LOG = workbook.excelImportErrors = [];
|
|
20914
21050
|
|
|
20915
21051
|
let strings = await readStrings(zip);
|
|
@@ -20926,6 +21062,10 @@ async function readWorkbook(zip, workbook) {
|
|
|
20926
21062
|
let file = relationships.byId[relId];
|
|
20927
21063
|
let name = attrs.name;
|
|
20928
21064
|
let state = attrs.state;
|
|
21065
|
+
let dim = sheetDimensions(relationships.bytes[file]);
|
|
21066
|
+
|
|
21067
|
+
workbook.options.columnWidth = dim.columnWidth || workbook.options.columnWidth;
|
|
21068
|
+
workbook.options.rowHeight = dim.rowHeight || workbook.options.rowHeight;
|
|
20929
21069
|
|
|
20930
21070
|
items.push({
|
|
20931
21071
|
workbook: workbook,
|
|
@@ -20935,7 +21075,11 @@ async function readWorkbook(zip, workbook) {
|
|
|
20935
21075
|
file: file,
|
|
20936
21076
|
options: {
|
|
20937
21077
|
state: state,
|
|
20938
|
-
name: name
|
|
21078
|
+
name: name,
|
|
21079
|
+
rows: Math.max(workbook.options.rows || 0, dim.rows),
|
|
21080
|
+
columns: Math.max(workbook.options.columns || 0, dim.cols),
|
|
21081
|
+
columnWidth: dim.columnWidth,
|
|
21082
|
+
rowHeight: dim.rowHeight
|
|
20939
21083
|
}
|
|
20940
21084
|
});
|
|
20941
21085
|
} else if (this.is(SEL_VIEW)) {
|
|
@@ -20965,43 +21109,63 @@ async function readWorkbook(zip, workbook) {
|
|
|
20965
21109
|
}
|
|
20966
21110
|
});
|
|
20967
21111
|
|
|
20968
|
-
|
|
20969
|
-
|
|
20970
|
-
|
|
20971
|
-
|
|
20972
|
-
|
|
20973
|
-
|
|
20974
|
-
|
|
20975
|
-
|
|
20976
|
-
|
|
20977
|
-
...item.options,
|
|
20978
|
-
rows: Math.max(workbook.options.rows || 0, dim.rows),
|
|
20979
|
-
columns: Math.max(workbook.options.columns || 0, dim.cols),
|
|
20980
|
-
columnWidth: dim.columnWidth,
|
|
20981
|
-
rowHeight: dim.rowHeight
|
|
20982
|
-
};
|
|
20983
|
-
}
|
|
21112
|
+
let loading = new Deferred();
|
|
21113
|
+
loading.progress(function(args) {
|
|
21114
|
+
if (progress) {
|
|
21115
|
+
progress.notify(args);
|
|
21116
|
+
}
|
|
21117
|
+
})
|
|
21118
|
+
.then(function() {
|
|
21119
|
+
let sheets = workbook.sheets();
|
|
21120
|
+
recalcSheets(sheets);
|
|
20984
21121
|
|
|
20985
|
-
|
|
21122
|
+
workbook.activeSheet(sheets[activeSheet]);
|
|
20986
21123
|
|
|
20987
|
-
|
|
20988
|
-
|
|
21124
|
+
if (progress) {
|
|
21125
|
+
progress.resolve();
|
|
21126
|
+
}
|
|
21127
|
+
});
|
|
20989
21128
|
|
|
20990
|
-
workbook
|
|
21129
|
+
loadSheets(items, workbook, loading);
|
|
20991
21130
|
}
|
|
20992
21131
|
|
|
20993
|
-
|
|
21132
|
+
function loadSheets(items, workbook, progress) {
|
|
21133
|
+
let ready = window.Promise.resolve();
|
|
20994
21134
|
for (let i = 0; i < items.length; i++) {
|
|
20995
|
-
|
|
20996
|
-
|
|
21135
|
+
(function(entry, i) {
|
|
21136
|
+
ready = ready.then(function() {
|
|
21137
|
+
let sheet = workbook.insertSheet(entry.options);
|
|
21138
|
+
sheet.suspendChanges(true);
|
|
21139
|
+
|
|
21140
|
+
let promise = queueSheet(sheet, entry);
|
|
21141
|
+
let args = {
|
|
21142
|
+
sheet: sheet,
|
|
21143
|
+
progress: i === 1 ? 1 : (i / (items.length - 1))
|
|
21144
|
+
};
|
|
20997
21145
|
|
|
20998
|
-
|
|
20999
|
-
|
|
21000
|
-
|
|
21146
|
+
promise.then(function() {
|
|
21147
|
+
progress.notify(args);
|
|
21148
|
+
});
|
|
21001
21149
|
|
|
21002
|
-
|
|
21003
|
-
|
|
21150
|
+
return promise;
|
|
21151
|
+
});
|
|
21152
|
+
})(items[i], i);
|
|
21004
21153
|
}
|
|
21154
|
+
|
|
21155
|
+
ready.then(function() {
|
|
21156
|
+
progress.resolve();
|
|
21157
|
+
});
|
|
21158
|
+
}
|
|
21159
|
+
|
|
21160
|
+
function queueSheet(sheet, ctx) {
|
|
21161
|
+
let deferred = new Deferred();
|
|
21162
|
+
|
|
21163
|
+
setTimeout(async function() {
|
|
21164
|
+
await readSheet(ctx.zip, ctx.file, sheet, ctx.strings, ctx.styles);
|
|
21165
|
+
deferred.resolve();
|
|
21166
|
+
}, 0);
|
|
21167
|
+
|
|
21168
|
+
return deferred;
|
|
21005
21169
|
}
|
|
21006
21170
|
|
|
21007
21171
|
function recalcSheets(sheets) {
|
|
@@ -21012,13 +21176,13 @@ function recalcSheets(sheets) {
|
|
|
21012
21176
|
}
|
|
21013
21177
|
}
|
|
21014
21178
|
|
|
21015
|
-
|
|
21179
|
+
function sheetDimensions(bytes) {
|
|
21016
21180
|
let ref, dim = {
|
|
21017
21181
|
rows: 0,
|
|
21018
21182
|
cols: 0
|
|
21019
21183
|
};
|
|
21020
21184
|
|
|
21021
|
-
|
|
21185
|
+
parseXML(bytes, {
|
|
21022
21186
|
enter: function(tag, attrs) {
|
|
21023
21187
|
if (tag === "dimension") {
|
|
21024
21188
|
ref = calc.parseReference(attrs.ref);
|
|
@@ -21076,6 +21240,7 @@ async function readSheet(zip, file, sheet, strings, styles) {
|
|
|
21076
21240
|
let valueFilterBlanks;
|
|
21077
21241
|
let valueFilterValues;
|
|
21078
21242
|
let filters = [];
|
|
21243
|
+
let deferredStyles = [];
|
|
21079
21244
|
|
|
21080
21245
|
ERROR_LOG = sheet._workbook.excelImportErrors;
|
|
21081
21246
|
|
|
@@ -21120,7 +21285,7 @@ async function readSheet(zip, file, sheet, strings, styles) {
|
|
|
21120
21285
|
|
|
21121
21286
|
let styleIndex = attrs.s;
|
|
21122
21287
|
if (styleIndex != null) {
|
|
21123
|
-
|
|
21288
|
+
deferredStyles.push({ ref: ref, sty: +styleIndex });
|
|
21124
21289
|
}
|
|
21125
21290
|
} else if (this.is(SEL_MERGE)) {
|
|
21126
21291
|
sheet.range(attrs.ref).merge();
|
|
@@ -21141,10 +21306,13 @@ async function readSheet(zip, file, sheet, strings, styles) {
|
|
|
21141
21306
|
}
|
|
21142
21307
|
if (attrs.style != null) {
|
|
21143
21308
|
// apply style on a whole range of columns
|
|
21144
|
-
|
|
21145
|
-
new
|
|
21146
|
-
|
|
21147
|
-
|
|
21309
|
+
deferredStyles.unshift({
|
|
21310
|
+
ref: new RangeRef(
|
|
21311
|
+
new CellRef(-Infinity, start),
|
|
21312
|
+
new CellRef(+Infinity, stop)
|
|
21313
|
+
),
|
|
21314
|
+
sty: +attrs.style
|
|
21315
|
+
});
|
|
21148
21316
|
}
|
|
21149
21317
|
} else if (this.is(SEL_ROW)) {
|
|
21150
21318
|
let row = integer(attrs.r) - 1;
|
|
@@ -21181,6 +21349,10 @@ async function readSheet(zip, file, sheet, strings, styles) {
|
|
|
21181
21349
|
if (target) {
|
|
21182
21350
|
sheet.range(attrs.ref).link(target);
|
|
21183
21351
|
}
|
|
21352
|
+
} else if (this.is(SEL_PROTECTION)) {
|
|
21353
|
+
if (attrs.sheet) {
|
|
21354
|
+
sheet.range(SHEETREF).enable(false);
|
|
21355
|
+
}
|
|
21184
21356
|
} else if (this.is(["autoFilter"])) {
|
|
21185
21357
|
filterRef = attrs.ref;
|
|
21186
21358
|
if (closed) {
|
|
@@ -21351,6 +21523,8 @@ async function readSheet(zip, file, sheet, strings, styles) {
|
|
|
21351
21523
|
}
|
|
21352
21524
|
});
|
|
21353
21525
|
|
|
21526
|
+
deferredStyles.forEach(({ ref, sty }) => applyStyle(sheet, ref, styles, sty));
|
|
21527
|
+
|
|
21354
21528
|
if (relationships.byType.comments) {
|
|
21355
21529
|
let commentFile = relative_file(file, relationships.byType.comments[0]);
|
|
21356
21530
|
await readComments(zip, commentFile, sheet);
|
|
@@ -21401,12 +21575,14 @@ async function readDrawings(zip, file, sheet) {
|
|
|
21401
21575
|
let relationships = await readRelationships(zip, relsFile);
|
|
21402
21576
|
|
|
21403
21577
|
if (relationships.byType.image) {
|
|
21404
|
-
|
|
21578
|
+
let relkeys = Object.keys(relationships.byId);
|
|
21579
|
+
for (let i = 0; i < relkeys.length; ++i) {
|
|
21580
|
+
let id = relkeys[i];
|
|
21405
21581
|
let img = relative_file(file, relationships.byId[id]);
|
|
21406
21582
|
let type = getContentType(img);
|
|
21407
21583
|
|
|
21408
21584
|
if (type) {
|
|
21409
|
-
let data = await zip.
|
|
21585
|
+
let data = await zip.file(img).async("arraybuffer");
|
|
21410
21586
|
let name = getFileName(img);
|
|
21411
21587
|
let blob = name && !(browser.edge)
|
|
21412
21588
|
? new window.File([ data ], name, { type: type })
|
|
@@ -21680,6 +21856,9 @@ function applyStyle(sheet, ref, styles, styleIndex) {
|
|
|
21680
21856
|
if (shouldSet("applyNumberFormat", "numFmtId")) {
|
|
21681
21857
|
setFormat(styles.numFmts[value] || DEFAULT_FORMATS[value]);
|
|
21682
21858
|
}
|
|
21859
|
+
if (shouldSet("applyProtection", "protection")) {
|
|
21860
|
+
range.enable(!xf.protection.locked);
|
|
21861
|
+
}
|
|
21683
21862
|
|
|
21684
21863
|
function setFormat(f) {
|
|
21685
21864
|
let format = typeof f == "string" ? f : f.formatCode;
|
|
@@ -21768,11 +21947,18 @@ function applyStyle(sheet, ref, styles, styleIndex) {
|
|
|
21768
21947
|
}
|
|
21769
21948
|
}
|
|
21770
21949
|
|
|
21771
|
-
|
|
21772
|
-
|
|
21773
|
-
|
|
21774
|
-
|
|
21775
|
-
|
|
21950
|
+
function parse(zip, file, callbacks) {
|
|
21951
|
+
return new window.Promise(resolve => {
|
|
21952
|
+
let obj = zip.file(file);
|
|
21953
|
+
if (obj) {
|
|
21954
|
+
obj.async("uint8array").then(bytes => {
|
|
21955
|
+
parseXML(bytes, callbacks);
|
|
21956
|
+
resolve();
|
|
21957
|
+
});
|
|
21958
|
+
} else {
|
|
21959
|
+
resolve();
|
|
21960
|
+
}
|
|
21961
|
+
});
|
|
21776
21962
|
}
|
|
21777
21963
|
|
|
21778
21964
|
async function readStrings(zip) {
|
|
@@ -21798,7 +21984,7 @@ async function readStrings(zip) {
|
|
|
21798
21984
|
}
|
|
21799
21985
|
|
|
21800
21986
|
async function readRelationships(zip, file) {
|
|
21801
|
-
let map = { byId: {}, byType: { theme: [] } };
|
|
21987
|
+
let map = { byId: {}, byType: { theme: [] }, bytes: {} };
|
|
21802
21988
|
await parse(zip, xl(file) + ".rels", {
|
|
21803
21989
|
enter: function(tag, attrs) {
|
|
21804
21990
|
if (tag === "Relationship") {
|
|
@@ -21811,6 +21997,18 @@ async function readRelationships(zip, file) {
|
|
|
21811
21997
|
}
|
|
21812
21998
|
}
|
|
21813
21999
|
});
|
|
22000
|
+
let names = [];
|
|
22001
|
+
let promises = [];
|
|
22002
|
+
Object.keys(map.byId).forEach(id => {
|
|
22003
|
+
let filename = map.byId[id];
|
|
22004
|
+
let obj = zip.file(xl(filename));
|
|
22005
|
+
if (obj) {
|
|
22006
|
+
names.push(filename);
|
|
22007
|
+
promises.push(obj.async("uint8array"));
|
|
22008
|
+
}
|
|
22009
|
+
});
|
|
22010
|
+
let data = await window.Promise.all(promises);
|
|
22011
|
+
names.forEach((name, i) => map.bytes[name] = data[i]);
|
|
21814
22012
|
return map;
|
|
21815
22013
|
}
|
|
21816
22014
|
|
|
@@ -21952,6 +22150,10 @@ async function readStyles(zip, theme) {
|
|
|
21952
22150
|
if (attrs.indent != null) {
|
|
21953
22151
|
xf.indent = integer(attrs.indent);
|
|
21954
22152
|
}
|
|
22153
|
+
} else if (tag == "protection") {
|
|
22154
|
+
xf.protection = {
|
|
22155
|
+
locked: bool(attrs.locked)
|
|
22156
|
+
};
|
|
21955
22157
|
}
|
|
21956
22158
|
}
|
|
21957
22159
|
},
|
|
@@ -21983,10 +22185,12 @@ async function readStyles(zip, theme) {
|
|
|
21983
22185
|
addBool("applyFill");
|
|
21984
22186
|
addBool("applyFont");
|
|
21985
22187
|
addBool("applyNumberFormat");
|
|
21986
|
-
addBool("applyProtection")
|
|
22188
|
+
if (addBool("applyProtection")) {
|
|
22189
|
+
xf.protection = { locked: true };
|
|
22190
|
+
}
|
|
21987
22191
|
function addBool(name) {
|
|
21988
22192
|
if (attrs[name] != null) {
|
|
21989
|
-
xf[name] = bool(attrs[name]);
|
|
22193
|
+
return xf[name] = bool(attrs[name]);
|
|
21990
22194
|
}
|
|
21991
22195
|
}
|
|
21992
22196
|
return xf;
|
|
@@ -22035,7 +22239,7 @@ async function readTheme(zip, rel) {
|
|
|
22035
22239
|
};
|
|
22036
22240
|
|
|
22037
22241
|
let file = xl(rel);
|
|
22038
|
-
if (zip.
|
|
22242
|
+
if (zip.file(file)) {
|
|
22039
22243
|
await parse(zip, file, {
|
|
22040
22244
|
enter: function(tag, attrs) {
|
|
22041
22245
|
if (this.is(SEL_SCHEME_SYSCLR)) {
|
|
@@ -22766,10 +22970,14 @@ class Workbook extends Observable {
|
|
|
22766
22970
|
}
|
|
22767
22971
|
|
|
22768
22972
|
fromFile(file) {
|
|
22769
|
-
|
|
22973
|
+
const deferred = new Deferred();
|
|
22974
|
+
|
|
22975
|
+
if (file && !this.trigger("excelImport", { file, deferred })) {
|
|
22770
22976
|
this._clearSheets();
|
|
22771
|
-
readExcel(file, this);
|
|
22977
|
+
readExcel(file, this, deferred);
|
|
22772
22978
|
}
|
|
22979
|
+
|
|
22980
|
+
return deferred.promise;
|
|
22773
22981
|
}
|
|
22774
22982
|
|
|
22775
22983
|
saveAsExcel(options) {
|
|
@@ -24267,6 +24475,11 @@ function binaryCompare(left, right, func) {
|
|
|
24267
24475
|
right = right.toLowerCase();
|
|
24268
24476
|
}
|
|
24269
24477
|
if (typeof right == typeof left) {
|
|
24478
|
+
// for issue https://github.com/telerik/kendo-ui-core/issues/6879, limitPrecision
|
|
24479
|
+
// digits got bumped to 16, but it's too much for the case 9.302 - 0.002 (issue
|
|
24480
|
+
// https://github.com/telerik/kendo-ui-core/issues/7170).
|
|
24481
|
+
left = maybeRoundFloatErrors(left, 15);
|
|
24482
|
+
right = maybeRoundFloatErrors(right, 15);
|
|
24270
24483
|
return func(left, right);
|
|
24271
24484
|
} else {
|
|
24272
24485
|
return new CalcError("VALUE");
|
|
@@ -32609,10 +32822,10 @@ defineBuiltinFunction('index', true, function () {
|
|
|
32609
32822
|
}
|
|
32610
32823
|
}
|
|
32611
32824
|
if (ref.width == 1) {
|
|
32612
|
-
return callback(ref.get(row - 1, 0));
|
|
32825
|
+
return callback(ref.get((row || 1) - 1, 0));
|
|
32613
32826
|
}
|
|
32614
32827
|
if (ref.height == 1) {
|
|
32615
|
-
return callback(ref.get(0, col - 1));
|
|
32828
|
+
return callback(ref.get(0, (col || 1) - 1));
|
|
32616
32829
|
}
|
|
32617
32830
|
} else {
|
|
32618
32831
|
callback(new CalcError('REF'));
|
|
@@ -43758,4 +43971,4 @@ const {
|
|
|
43758
43971
|
defineAlias
|
|
43759
43972
|
} = calc.runtime;
|
|
43760
43973
|
|
|
43761
|
-
export { CalcError, CellRef, Context, Matrix, NULLREF, NameRef, Range$1 as Range, RangeRef, Ref, Sheet, SpreadsheetWidget, UnionRef, View, Workbook, calc, dateToSerial, defineAlias, defineFunction, packDate, packTime, serialToDate, unpackDate, unpackTime };
|
|
43974
|
+
export { CalcError, CellRef, Context, Deferred, Matrix, NULLREF, NameRef, Range$1 as Range, RangeRef, Ref, Sheet, SpreadsheetWidget, UnionRef, View, Workbook, calc, dateToSerial, defineAlias, defineFunction, packDate, packTime, serialToDate, unpackDate, unpackTime };
|