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