@univerjs/engine-formula 0.4.0-alpha.0 → 0.4.0-alpha.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/lib/cjs/index.js +1 -1
- package/lib/es/index.js +24 -9
- package/lib/umd/index.js +1 -1
- package/package.json +5 -7
package/lib/es/index.js
CHANGED
|
@@ -5478,6 +5478,8 @@ const _ArrayValueObject = class _ArrayValueObject extends BaseValueObject {
|
|
|
5478
5478
|
valueObject.getValue()
|
|
5479
5479
|
);
|
|
5480
5480
|
rowPositions != null && rowPositions.forEach((row) => {
|
|
5481
|
+
if (row < startRow || row > startRow + rowCount - 1)
|
|
5482
|
+
return;
|
|
5481
5483
|
const r = row - startRow;
|
|
5482
5484
|
result[r] == null && (result[r] = []), result[r][column] = BooleanValueObject.create(!0);
|
|
5483
5485
|
});
|
|
@@ -7590,7 +7592,10 @@ const _ColumnReferenceObject = class _ColumnReferenceObject extends BaseReferenc
|
|
|
7590
7592
|
const columnReferenceObject = referenceObject;
|
|
7591
7593
|
if (columnReferenceObject.getForcedSheetName() !== void 0 && columnReferenceObject.getForcedSheetName() !== "")
|
|
7592
7594
|
return ErrorValueObject.create(ErrorType$1.REF);
|
|
7593
|
-
const currentRangeData = this.getRangeData(), newColumnRange = columnReferenceObject.getRangeData(), newColumn = newColumnRange.startColumn
|
|
7595
|
+
const currentRangeData = this.getRangeData(), newColumnRange = columnReferenceObject.getRangeData(), newColumn = newColumnRange.startColumn;
|
|
7596
|
+
if (newColumn >= currentRangeData.startColumn && newColumn <= currentRangeData.endColumn)
|
|
7597
|
+
return this;
|
|
7598
|
+
const column = currentRangeData.startColumn;
|
|
7594
7599
|
return newColumn > column ? currentRangeData.endColumn = newColumn : (currentRangeData.startColumn = newColumn, currentRangeData.endColumn = column), newColumnRange.startAbsoluteRefType && (currentRangeData.endAbsoluteRefType = newColumnRange.startAbsoluteRefType), currentRangeData.rangeType = RANGE_TYPE.COLUMN, this.setToken(`${this.getToken()}${matchToken.COLON}${columnReferenceObject.getToken()}`), this;
|
|
7595
7600
|
}
|
|
7596
7601
|
};
|
|
@@ -7618,7 +7623,10 @@ const _RowReferenceObject = class _RowReferenceObject extends BaseReferenceObjec
|
|
|
7618
7623
|
const rowReferenceObject = referenceObject;
|
|
7619
7624
|
if (rowReferenceObject.getForcedSheetName() !== void 0 && rowReferenceObject.getForcedSheetName() !== "")
|
|
7620
7625
|
return ErrorValueObject.create(ErrorType$1.REF);
|
|
7621
|
-
const currentRangeData = this.getRangeData(), newRowRange = rowReferenceObject.getRangeData(), newRow = newRowRange.startRow
|
|
7626
|
+
const currentRangeData = this.getRangeData(), newRowRange = rowReferenceObject.getRangeData(), newRow = newRowRange.startRow;
|
|
7627
|
+
if (newRow >= currentRangeData.startRow && newRow <= currentRangeData.endRow)
|
|
7628
|
+
return this;
|
|
7629
|
+
const row = currentRangeData.startRow;
|
|
7622
7630
|
return newRow > row ? currentRangeData.endRow = newRow : (currentRangeData.startRow = newRow, currentRangeData.endRow = row), newRowRange.startAbsoluteRefType && (currentRangeData.endAbsoluteRefType = newRowRange.startAbsoluteRefType), currentRangeData.rangeType = RANGE_TYPE.ROW, this.setToken(`${this.getToken()}${matchToken.COLON}${rowReferenceObject.getToken()}`), this;
|
|
7623
7631
|
}
|
|
7624
7632
|
};
|
|
@@ -11395,23 +11403,30 @@ const _Datedif = class _Datedif extends BaseFunction {
|
|
|
11395
11403
|
}
|
|
11396
11404
|
_getResultByUnit(startDateSerialNumber, endDateSerialNumber, unit) {
|
|
11397
11405
|
const startDateDate = excelSerialToDate(startDateSerialNumber), startYear = startDateDate.getUTCFullYear(), startMonth = startDateDate.getUTCMonth() + 1, startDay = startDateDate.getUTCDate(), endDateDate = excelSerialToDate(endDateSerialNumber), endYear = endDateDate.getUTCFullYear(), endMonth = endDateDate.getUTCMonth() + 1, endDay = endDateDate.getUTCDate(), unitValue = `${unit.getValue()}`.toLocaleUpperCase();
|
|
11398
|
-
let
|
|
11406
|
+
let diff = 0, newDate;
|
|
11399
11407
|
switch (unitValue) {
|
|
11400
11408
|
case "Y":
|
|
11401
|
-
|
|
11409
|
+
diff = endYear - startYear, (endMonth < startMonth || endMonth === startMonth && endDay < startDay) && (diff -= 1);
|
|
11410
|
+
break;
|
|
11402
11411
|
case "M":
|
|
11403
|
-
|
|
11412
|
+
diff = (endYear - startYear) * 12 + endMonth - startMonth, endDay < startDay && (diff -= 1);
|
|
11413
|
+
break;
|
|
11404
11414
|
case "D":
|
|
11405
|
-
|
|
11415
|
+
diff = Math.floor(endDateSerialNumber) - Math.floor(startDateSerialNumber);
|
|
11416
|
+
break;
|
|
11406
11417
|
case "MD":
|
|
11407
|
-
|
|
11418
|
+
diff = endDay - startDay, endDay < startDay && (newDate = new Date(Date.UTC(endYear, endMonth - 1, 0)), diff += getDaysInMonth(newDate.getUTCFullYear(), newDate.getUTCMonth()));
|
|
11419
|
+
break;
|
|
11408
11420
|
case "YM":
|
|
11409
|
-
|
|
11421
|
+
diff = endMonth - startMonth, (endMonth < startMonth || endMonth === startMonth && endDay < startDay) && (diff += 12), endDay < startDay && (diff -= 1);
|
|
11422
|
+
break;
|
|
11410
11423
|
case "YD":
|
|
11411
|
-
|
|
11424
|
+
newDate = new Date(Date.UTC(startYear, endMonth - 1, endDay)), (endMonth < startMonth || endMonth === startMonth && endDay < startDay) && (newDate = new Date(Date.UTC(startYear + 1, endMonth - 1, endDay))), diff = Math.floor(excelDateSerial(newDate)) - Math.floor(startDateSerialNumber);
|
|
11425
|
+
break;
|
|
11412
11426
|
default:
|
|
11413
11427
|
return ErrorValueObject.create(ErrorType$1.NUM);
|
|
11414
11428
|
}
|
|
11429
|
+
return NumberValueObject.create(diff);
|
|
11415
11430
|
}
|
|
11416
11431
|
};
|
|
11417
11432
|
__name(_Datedif, "Datedif");
|