1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346 | 1×
1×
1×
19226×
19226×
19226×
19226×
19226×
19226×
19225×
19225×
1×
19226×
19226×
19226×
19226×
19226×
19226×
19224×
19224×
19224×
19224×
19224×
19224×
19224×
19224×
174×
174×
174×
174×
174×
174×
174×
174×
174×
174×
110×
110×
64×
174×
187×
187×
187×
187×
24357×
24357×
24357×
24357×
537212×
215×
215×
536997×
536997×
536997×
2818×
2510×
189×
111×
78×
2321×
2510×
2510×
634×
634×
145×
308×
308×
2818×
534179×
524383×
20568×
20568×
20379×
75×
75×
20304×
20303×
20303×
1×
20568×
503815×
536997×
23387×
23387×
23387×
10×
23387×
536997×
24357×
19050×
19050×
19050×
105821×
6×
6×
105815×
696×
696×
105119×
105119×
105119×
3909412×
3909412×
3909412×
3909412×
183×
3909411×
179×
179×
2252×
5687×
179×
5508×
5508×
4951×
5508×
3435×
5508×
1933×
1933×
5508×
3909232×
79×
171×
171×
171×
171×
3909153×
62×
159×
159×
159×
159×
3909411×
1882×
1882×
3907529×
51×
51×
3907478×
3871×
3871×
3871×
3907478×
3907478×
105118×
19223×
1×
1×
22903×
22902×
10×
22892×
99×
99×
99×
22793×
20470×
2323×
2323×
1832×
1832×
1×
1×
1×
2323×
1×
1×
1×
4×
4×
4×
4×
3×
14×
9×
9×
2×
5×
2×
2×
5×
1×
5×
2×
11×
2×
5×
5×
4×
1×
1×
7686×
7686×
7686×
7686×
7686×
19336×
2206×
2206×
19336×
862×
862×
7473×
1×
1×
7472×
862×
862×
19336×
1228×
1142×
1142×
972×
1228×
1110×
1228×
1228×
6392×
1228×
19336×
7686×
7686×
19336×
19336×
1×
| define(["require", "exports", "../index", "../common/index", "../common/index", "./index", "@syncfusion/ej2-base", "./../index"], function (require, exports, index_1, index_2, index_3, index_4, ej2_base_1, index_5) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function getData(context, address, columnWiseData, valueOnly, frozenIndexes, filterDialog, formulaCellRef, idx, skipHiddenRows, commonAddr, dateValueForSpecificColIdx, dateColData) {
if (skipHiddenRows === void 0) { skipHiddenRows = true; }
return new Promise(function (resolve) {
resolve((function () {
var sheetIdx;
var lastIndex = address.lastIndexOf('!');
if (lastIndex > -1) {
sheetIdx = index_1.getSheetIndex(context, address.substring(0, lastIndex));
address = address.substring(lastIndex + 1);
}
else {
sheetIdx = context.activeSheetIndex;
}
var sheet = index_1.getSheet(context, sheetIdx);
var indexes = index_2.getIndexesFromAddress(commonAddr || address);
var args = {
sheet: sheet, indexes: indexes, formulaCellRef: formulaCellRef, sheetIndex: idx,
promise: new Promise(function (resolve) { resolve((function () { })()); })
};
context.notify(index_2.updateSheetFromDataSource, args);
return args.promise.then(function () {
var i;
var row;
var data;
var sRow = indexes[0];
var frozenRow = context.frozenRowCount(sheet);
var frozenCol = context.frozenColCount(sheet);
var isDateCol = !!dateColData;
if (columnWiseData) {
data = [];
var index_6;
var cells_1;
var parsedNumVal_1;
var key_1;
var cellProp_1;
var localeObj_1;
var intl_1;
var autoDetectFormatFn_1;
if (valueOnly) {
localeObj_1 = ej2_base_1.getNumericObject(context.locale);
intl_1 = new ej2_base_1.Internationalization(context.locale);
}
else {
autoDetectFormatFn_1 = index_5.getAutoDetectFormatParser(context);
}
address.split(',').forEach(function (addr, addrIdx) {
indexes = index_1.getRangeIndexes(addr);
index_6 = 0;
sRow = indexes[0];
while (sRow <= indexes[2]) {
cells_1 = data[index_6] || {};
row = index_4.getRow(sheet, sRow);
i = indexes[1];
while (i <= indexes[3]) {
if (skipHiddenRows && index_4.isHiddenRow(sheet, sRow) && !filterDialog) {
sRow++;
continue;
}
key_1 = index_2.getColumnHeaderText(i + 1);
var cell = row ? index_4.getCell(sRow, i, sheet) : null;
if (valueOnly) {
if (cell && (cell.value || cell.value === 0)) {
if (cell.formattedText && cell.format && !cell.format.includes('*')) {
if (index_5.isCustomDateTime(cell.format, false)) {
cells_1[key_1] = index_2.intToDate(cell.value);
}
else {
cells_1[key_1] = cell.formattedText.toString().trim();
}
}
else {
cells_1[key_1] = getValueFromFormat(context, cell, sRow, i, false, intl_1);
}
cellProp_1 = cell.value;
if (typeof cellProp_1 === 'string') {
Iif (localeObj_1.decimal !== '.' && cellProp_1.includes(localeObj_1.decimal)) {
parsedNumVal_1 = cellProp_1.replace(localeObj_1.decimal, '.');
if (index_3.isNumber(parsedNumVal_1)) {
cellProp_1 = parseFloat(parsedNumVal_1);
}
}
else if (index_3.isNumber(cellProp_1)) {
cellProp_1 = parseFloat(cellProp_1);
}
}
}
else {
cells_1[key_1] = '';
cellProp_1 = null;
}
cells_1[key_1 + "_value"] = cellProp_1;
}
else {
if ((cell && (cell.formula || !ej2_base_1.isNullOrUndefined(cell.value))) || Object.keys(cells_1).length) {
if (i === dateValueForSpecificColIdx) {
cellProp_1 = { value: getValueFromFormat(context, cell, sRow, i, true) };
if (cellProp_1.value && typeof cellProp_1.value === 'string') {
if (index_3.isNumber(cellProp_1.value)) {
Eif (!cell.format || cell.format !== '@') {
cellProp_1.value = parseFloat(cellProp_1.value);
}
}
else if (!cell.format) {
autoDetectFormatFn_1(cell);
if (index_3.isNumber(cell.value)) {
cellProp_1.value = parseFloat(cell.value);
}
}
}
cells_1[key_1] = ej2_base_1.extend({}, cell, cellProp_1);
}
else {
cells_1[key_1] = cell;
}
}
}
if (i === indexes[3] && Object.keys(cells_1).length) {
cells_1['__rowIndex'] = (sRow + 1).toString();
data[index_6] = cells_1;
if (isDateCol && addrIdx === 0 && !index_1.isFilterHidden(sheet, sRow)) {
dateColData.push(cells_1);
}
index_6++;
}
i++;
}
sRow++;
}
});
}
else {
data = new Map();
var checkFrozenIdx = !!(!valueOnly && frozenIndexes && frozenIndexes.length);
while (sRow <= indexes[2]) {
if (checkFrozenIdx && sRow >= frozenRow && sRow < frozenIndexes[0]) {
sRow = frozenIndexes[0];
continue;
}
if (!valueOnly && index_4.isHiddenRow(sheet, sRow)) {
sRow++;
continue;
}
row = index_4.getRow(sheet, sRow);
i = indexes[1];
while (i <= indexes[3]) {
var eventArgs = { cell: index_4.getCell(sRow, i, sheet), address: index_2.getCellAddress(sRow, i),
rowIndex: sRow, colIndex: i };
context.trigger(index_3.queryCellInfo, eventArgs);
var cellObj = index_4.getCell(sRow, i, sheet, false, true);
if (cellObj.formula && cellObj.formula.toUpperCase().includes('UNIQUE')) {
context.notify(index_5.calculateFormula, { cell: cellObj, rowIdx: sRow, colIdx: i, sheetIndex: context.activeSheetIndex,
address: eventArgs.address });
}
if (cellObj.colSpan > 1 && cellObj.rowSpan > 1) {
var cell = void 0;
for (var j = sRow, len = sRow + cellObj.rowSpan; j < len; j++) {
for (var k = i, len_1 = i + cellObj.colSpan; k < len_1; k++) {
if (j === sRow && k === i) {
continue;
}
cell = new Object();
if (j !== sRow) {
cell.rowSpan = sRow - j;
}
if (k !== i) {
cell.colSpan = i - k;
}
if (sheet.rows[j] && sheet.rows[j].cells &&
sheet.rows[j].cells[k]) {
delete sheet.rows[j].cells[k].value;
delete sheet.rows[j].cells[k].formula;
}
index_5.setCell(j, k, sheet, cell, true);
}
}
}
else if (cellObj.colSpan > 1) {
for (var j = i + 1, len = i + cellObj.colSpan; j < len; j++) {
index_5.setCell(sRow, j, sheet, { colSpan: i - j }, true);
Eif (sheet.rows[sRow] && sheet.rows[sRow].cells &&
sheet.rows[sRow].cells[j]) {
delete sheet.rows[sRow].cells[j].value;
delete sheet.rows[sRow].cells[j].formula;
}
}
}
else if (cellObj.rowSpan > 1) {
for (var j = sRow + 1, len = sRow + cellObj.rowSpan; j < len; j++) {
index_5.setCell(j, i, sheet, { rowSpan: sRow - j }, true);
Eif (sheet.rows[j] && sheet.rows[j].cells &&
sheet.rows[j].cells[i]) {
delete sheet.rows[j].cells[i].value;
delete sheet.rows[j].cells[i].formula;
}
}
}
if (!valueOnly && index_4.isHiddenCol(sheet, i)) {
i++;
continue;
}
if (checkFrozenIdx && i >= frozenCol && i < frozenIndexes[1]) {
i = frozenIndexes[1];
continue;
}
if (cellObj.style) {
var style = {};
Object.assign(style, cellObj.style);
cellObj.style = style;
}
data.set(eventArgs.address, cellObj);
i++;
}
sRow++;
}
}
return data;
});
})());
});
}
exports.getData = getData;
function getValueFromFormat(context, cell, rowIdx, colIdx, getIntValueFromDate, intl) {
if (cell) {
if (ej2_base_1.isNullOrUndefined(cell.value)) {
return '';
}
if (cell.format) {
var args = { value: cell.value, formattedText: cell.value, cell: cell, format: cell.format,
checkDate: !getIntValueFromDate, rowIndex: rowIdx, colIndex: colIdx, dataUpdate: true };
context.notify(index_3.getFormattedCellObject, args);
return args.dateObj && args.dateObj.toString() !== 'Invalid Date' ? args.dateObj : (getIntValueFromDate ? args.value :
typeof args.formattedText === 'string' ? args.formattedText.trim() : args.formattedText);
}
else if (getIntValueFromDate) {
return cell.value;
}
else {
var cellVal = cell.value;
if (index_3.isNumber(cellVal)) {
cellVal = Number(cell.value).toString();
if (cellVal.includes('.') || cellVal.length > 11) {
var options = { args: { value: cellVal, updateValue: true }, fResult: cellVal,
cellVal: cellVal, intl: intl };
context.notify(index_1.parseDecimalNumber, options);
cellVal = options.fResult;
}
}
return cellVal;
}
}
else {
return '';
}
}
exports.getValueFromFormat = getValueFromFormat;
function getModel(model, idx) {
var diff;
var j;
var prevIdx;
if (ej2_base_1.isUndefined(model[idx]) || !(model[idx] && model[idx].index === idx)) {
for (var i = 0; i <= idx; i++) {
if (model && model[i]) {
diff = model[i].index - i;
if (diff > 0) {
model.forEach(function (value, index) {
if (value && value.index) {
prevIdx = value.index;
j = 1;
}
if (value && !value.index && index !== 0) {
value.index = prevIdx + j;
}
j++;
});
while (diff--) {
model.splice(i, 0, null);
}
i += diff;
}
}
else Eif (model) {
model[i] = null;
}
else {
model = [];
}
}
}
return model[idx];
}
exports.getModel = getModel;
function processIdx(model, isSheet, context) {
var j;
var diff = 0;
var cnt;
var len = model.length;
var _loop_1 = function (i) {
if (!ej2_base_1.isNullOrUndefined(model[i]) && !ej2_base_1.isUndefined(model[i].index)) {
cnt = diff = model[i].index - i;
delete model[i].index;
}
if (diff > 0) {
j = 0;
while (diff--) {
if (isSheet) {
context.createSheet(i + j);
j++;
}
else {
model.splice(i, 0, null);
}
}
i += cnt;
len += cnt;
}
if (isSheet) {
if (model[i].id < 1) {
model[i].id = index_4.getMaxSheetId(context.sheets);
if (model[i].properties) {
model[i].properties.id = model[i].id;
}
}
if (!model[i].name) {
context.setSheetPropertyOnMute(model[i], 'name', 'Sheet' + index_4.getSheetNameCount(context));
}
var cellCnt_1 = 0;
model[i].rows.forEach(function (row) {
cellCnt_1 = Math.max(cellCnt_1, (row && row.cells && row.cells.length - 1) || 0);
});
context.setSheetPropertyOnMute(model[i], 'usedRange', { rowIndex: model[i].rows.length ? model[i].rows.length - 1 : 0,
colIndex: cellCnt_1 });
}
out_i_1 = i;
};
var out_i_1;
for (var i = 0; i < len; i++) {
_loop_1(i);
i = out_i_1;
}
}
exports.processIdx = processIdx;
});
|