ooxml-core 0.16.0 → 0.18.0
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/automation/index.cjs +867 -360
- package/dist/automation/index.mjs +867 -360
- package/dist/docx/document-stats.d.ts +18 -0
- package/dist/docx/document-stats.d.ts.map +1 -0
- package/dist/docx/index.cjs +34 -0
- package/dist/docx/index.d.ts +1 -0
- package/dist/docx/index.d.ts.map +1 -1
- package/dist/docx/index.mjs +33 -1
- package/dist/xlsx/formula/editor-text.d.ts +60 -0
- package/dist/xlsx/formula/editor-text.d.ts.map +1 -0
- package/dist/xlsx/formula/engine-core.d.ts +9 -0
- package/dist/xlsx/formula/engine-core.d.ts.map +1 -1
- package/dist/xlsx/formula/engine-host.d.ts +2 -0
- package/dist/xlsx/formula/engine-host.d.ts.map +1 -1
- package/dist/xlsx/formula/functions/bonds.d.ts +3 -0
- package/dist/xlsx/formula/functions/bonds.d.ts.map +1 -0
- package/dist/xlsx/formula/functions/coupons.d.ts +21 -0
- package/dist/xlsx/formula/functions/coupons.d.ts.map +1 -0
- package/dist/xlsx/formula/functions/depreciation.d.ts +0 -1
- package/dist/xlsx/formula/functions/depreciation.d.ts.map +1 -1
- package/dist/xlsx/formula/functions/financial.d.ts.map +1 -1
- package/dist/xlsx/formula/functions/securities.d.ts +3 -0
- package/dist/xlsx/formula/functions/securities.d.ts.map +1 -0
- package/dist/xlsx/formula/functions/text-extra.d.ts.map +1 -1
- package/dist/xlsx/formula/functions/text-regex.d.ts +5 -0
- package/dist/xlsx/formula/functions/text-regex.d.ts.map +1 -0
- package/dist/xlsx/formula/index.d.ts +1 -0
- package/dist/xlsx/formula/index.d.ts.map +1 -1
- package/dist/xlsx/index.cjs +1021 -343
- package/dist/xlsx/index.mjs +1008 -344
- package/dist/xlsx/load/index.cjs +804 -330
- package/dist/xlsx/load/index.mjs +804 -330
- package/dist/xlsx/model.d.ts +9 -0
- package/dist/xlsx/model.d.ts.map +1 -1
- package/dist/xlsx/read/load.d.ts.map +1 -1
- package/dist/xlsx/read/workbook-part.d.ts +5 -0
- package/dist/xlsx/read/workbook-part.d.ts.map +1 -1
- package/dist/xlsx/write/workbook-part.d.ts.map +1 -1
- package/package.json +2 -1
|
@@ -9866,8 +9866,14 @@ function parseWorkbookPart(xml) {
|
|
|
9866
9866
|
const protection2 = xFirst(root, "workbookProtection");
|
|
9867
9867
|
const password = att(protection2, "workbookPassword");
|
|
9868
9868
|
const modernHash = readModernHash(protection2, "workbook");
|
|
9869
|
-
const
|
|
9869
|
+
const calcPr = xFirst(root, "calcPr");
|
|
9870
|
+
const calcMode = att(calcPr, "calcMode");
|
|
9871
|
+
const iterate = boolAttr(calcPr, "iterate", false) ? {
|
|
9872
|
+
count: numAttr(calcPr, "iterateCount") ?? 100,
|
|
9873
|
+
delta: numAttr(calcPr, "iterateDelta") ?? 1e-3
|
|
9874
|
+
} : void 0;
|
|
9870
9875
|
return {
|
|
9876
|
+
...iterate ? { iterate } : {},
|
|
9871
9877
|
...password ? { workbookPasswordHash: password } : {},
|
|
9872
9878
|
...modernHash ? { workbookModernHash: modernHash } : {},
|
|
9873
9879
|
...calcMode === "manual" ? { calcMode: "manual" } : {},
|
|
@@ -11242,6 +11248,7 @@ async function loadXlsx(input) {
|
|
|
11242
11248
|
if (book.workbookPasswordHash) workbook.workbookPasswordHash = book.workbookPasswordHash;
|
|
11243
11249
|
if (book.workbookModernHash) workbook.workbookModernHash = book.workbookModernHash;
|
|
11244
11250
|
if (book.calcMode) workbook.calcMode = book.calcMode;
|
|
11251
|
+
if (book.iterate) workbook.iterate = book.iterate;
|
|
11245
11252
|
if (signatures.hasSignatures)
|
|
11246
11253
|
workbook.signatures = { count: signatures.signatureCount, parts: signatures.signaturePaths };
|
|
11247
11254
|
if (!sheets.length) throw new Error("XLSX workbook has no sheets");
|
|
@@ -15659,6 +15666,67 @@ var ENGINEERING_FUNCTIONS = [
|
|
|
15659
15666
|
)
|
|
15660
15667
|
];
|
|
15661
15668
|
|
|
15669
|
+
// src/xlsx/formula/functions/coupons.ts
|
|
15670
|
+
var C8 = "Financial";
|
|
15671
|
+
function checkSecurity(settlement, maturity, frequency2, basis) {
|
|
15672
|
+
if (![1, 2, 4].includes(frequency2) || basis < 0 || basis > 4 || settlement >= maturity)
|
|
15673
|
+
fail(ERR.NUM);
|
|
15674
|
+
}
|
|
15675
|
+
function couponFacts(settlement, maturity, frequency2, basis, ctx) {
|
|
15676
|
+
const [s, m] = [Math.floor(settlement), Math.floor(maturity)];
|
|
15677
|
+
checkSecurity(s, m, frequency2, basis);
|
|
15678
|
+
const months = 12 / frequency2;
|
|
15679
|
+
const { year, month, day } = serialToYmd(m, ctx.date1904);
|
|
15680
|
+
const monthEnd = day === daysInMonth(year, month);
|
|
15681
|
+
let count2 = 0;
|
|
15682
|
+
let next = m;
|
|
15683
|
+
let previous = addMonths(m, -months, ctx, monthEnd);
|
|
15684
|
+
while (previous > s) {
|
|
15685
|
+
count2 += 1;
|
|
15686
|
+
next = previous;
|
|
15687
|
+
previous = addMonths(m, -months * (count2 + 1), ctx, monthEnd);
|
|
15688
|
+
}
|
|
15689
|
+
count2 += 1;
|
|
15690
|
+
const dayCount = (a, b, european) => basis === 0 || basis === 4 ? days360(a, b, basis === 4 || european, ctx) : b - a;
|
|
15691
|
+
const daysSincePrevious = dayCount(previous, s, false);
|
|
15692
|
+
const daysInPeriod = basis === 1 ? next - previous : basis === 3 ? 365 / frequency2 : 360 / frequency2;
|
|
15693
|
+
const daysToNext = basis === 0 ? daysInPeriod - daysSincePrevious : basis === 4 ? days360(s, next, true, ctx) : next - s;
|
|
15694
|
+
return { previous, next, count: count2, daysSincePrevious, daysInPeriod, daysToNext };
|
|
15695
|
+
}
|
|
15696
|
+
var security = (name, description, pick3) => spec(
|
|
15697
|
+
name,
|
|
15698
|
+
C8,
|
|
15699
|
+
`${name}(settlement, maturity, frequency, [basis])`,
|
|
15700
|
+
description,
|
|
15701
|
+
3,
|
|
15702
|
+
4,
|
|
15703
|
+
(args, ctx) => pick3(
|
|
15704
|
+
couponFacts(
|
|
15705
|
+
serialArg(args[0]),
|
|
15706
|
+
serialArg(args[1]),
|
|
15707
|
+
int3(args[2]),
|
|
15708
|
+
args.length > 3 && args[3] !== null ? int3(args[3]) : 0,
|
|
15709
|
+
ctx
|
|
15710
|
+
)
|
|
15711
|
+
)
|
|
15712
|
+
);
|
|
15713
|
+
var COUPON_FUNCTIONS = [
|
|
15714
|
+
security("COUPPCD", "The coupon date before the settlement date.", (f) => f.previous),
|
|
15715
|
+
security("COUPNCD", "The coupon date after the settlement date.", (f) => f.next),
|
|
15716
|
+
security("COUPNUM", "The number of coupons between settlement and maturity.", (f) => f.count),
|
|
15717
|
+
security(
|
|
15718
|
+
"COUPDAYBS",
|
|
15719
|
+
"The days from the start of the coupon period to settlement.",
|
|
15720
|
+
(f) => f.daysSincePrevious
|
|
15721
|
+
),
|
|
15722
|
+
security(
|
|
15723
|
+
"COUPDAYS",
|
|
15724
|
+
"The days in the coupon period that contains the settlement date.",
|
|
15725
|
+
(f) => f.daysInPeriod
|
|
15726
|
+
),
|
|
15727
|
+
security("COUPDAYSNC", "The days from settlement to the next coupon date.", (f) => f.daysToNext)
|
|
15728
|
+
];
|
|
15729
|
+
|
|
15662
15730
|
// src/xlsx/formula/functions/financial-core.ts
|
|
15663
15731
|
function pmt(rate, nper, pv2, fv2 = 0, type = 0) {
|
|
15664
15732
|
if (nper === 0) fail(ERR.NUM);
|
|
@@ -15728,12 +15796,185 @@ function cumulative(args, principal) {
|
|
|
15728
15796
|
return total2;
|
|
15729
15797
|
}
|
|
15730
15798
|
|
|
15799
|
+
// src/xlsx/formula/functions/bonds.ts
|
|
15800
|
+
var C9 = "Financial";
|
|
15801
|
+
var basisOf = (args, index2) => {
|
|
15802
|
+
const basis = args.length > index2 && args[index2] !== null ? int3(args[index2]) : 0;
|
|
15803
|
+
if (basis < 0 || basis > 4) fail(ERR.NUM);
|
|
15804
|
+
return basis;
|
|
15805
|
+
};
|
|
15806
|
+
function pricePerHundred(facts, rate, yld, redemption, frequency2) {
|
|
15807
|
+
const { count: n, daysSincePrevious: a, daysInPeriod: e, daysToNext: dsc } = facts;
|
|
15808
|
+
const coupon = 100 * rate / frequency2;
|
|
15809
|
+
const accrued = coupon * (a / e);
|
|
15810
|
+
if (n === 1) return (redemption + coupon) / (1 + dsc / e * yld / frequency2) - accrued;
|
|
15811
|
+
let price = redemption / (1 + yld / frequency2) ** (n - 1 + dsc / e);
|
|
15812
|
+
for (let k = 1; k <= n; k++) price += coupon / (1 + yld / frequency2) ** (k - 1 + dsc / e);
|
|
15813
|
+
return price - accrued;
|
|
15814
|
+
}
|
|
15815
|
+
function bondOf(args, ctx, redemptionAt, basisAt) {
|
|
15816
|
+
const frequency2 = int3(args[5]);
|
|
15817
|
+
const facts = couponFacts(
|
|
15818
|
+
serialArg(args[0]),
|
|
15819
|
+
serialArg(args[1]),
|
|
15820
|
+
frequency2,
|
|
15821
|
+
basisOf(args, basisAt),
|
|
15822
|
+
ctx
|
|
15823
|
+
);
|
|
15824
|
+
return { facts, rate: num2(args[2]), redemption: num2(args[redemptionAt]), frequency: frequency2 };
|
|
15825
|
+
}
|
|
15826
|
+
function duration(bond, yld) {
|
|
15827
|
+
const { facts, rate, frequency: frequency2 } = bond;
|
|
15828
|
+
const { count: n, daysInPeriod: e, daysToNext: dsc } = facts;
|
|
15829
|
+
const coupon = 100 * rate / frequency2;
|
|
15830
|
+
let weighted = 0;
|
|
15831
|
+
let total2 = 0;
|
|
15832
|
+
for (let k = 1; k <= n; k++) {
|
|
15833
|
+
const periods = k - 1 + dsc / e;
|
|
15834
|
+
const flow = k === n ? coupon + 100 : coupon;
|
|
15835
|
+
const value = flow / (1 + yld / frequency2) ** periods;
|
|
15836
|
+
weighted += periods / frequency2 * value;
|
|
15837
|
+
total2 += value;
|
|
15838
|
+
}
|
|
15839
|
+
return weighted / total2;
|
|
15840
|
+
}
|
|
15841
|
+
function quasiPeriods(anchor, from, to, frequency2, ctx) {
|
|
15842
|
+
const months = 12 / frequency2;
|
|
15843
|
+
const { year, month, day } = serialToYmd(anchor, ctx.date1904);
|
|
15844
|
+
const monthEnd = day === daysInMonth(year, month);
|
|
15845
|
+
const at = (k) => addMonths(anchor, k * months, ctx, monthEnd);
|
|
15846
|
+
let back = 0;
|
|
15847
|
+
while (at(back) > from) back -= 1;
|
|
15848
|
+
const dates = [];
|
|
15849
|
+
for (let k = back; ; k++) {
|
|
15850
|
+
dates.push(at(k));
|
|
15851
|
+
if (at(k) >= to) break;
|
|
15852
|
+
}
|
|
15853
|
+
return dates;
|
|
15854
|
+
}
|
|
15855
|
+
function accruedInterest(args, ctx) {
|
|
15856
|
+
const issue = serialArg(args[0]);
|
|
15857
|
+
const first4 = serialArg(args[1]);
|
|
15858
|
+
const settlement = serialArg(args[2]);
|
|
15859
|
+
const [rate, par] = [num2(args[3]), optNum(args, 4, 1e3)];
|
|
15860
|
+
const frequency2 = int3(args[5]);
|
|
15861
|
+
const basis = basisOf(args, 6);
|
|
15862
|
+
const fromIssue = args.length > 7 && args[7] !== null ? bool(args[7]) : true;
|
|
15863
|
+
if (rate <= 0 || par <= 0 || ![1, 2, 4].includes(frequency2) || issue >= settlement) fail(ERR.NUM);
|
|
15864
|
+
const start = fromIssue ? issue : Math.max(issue, first4);
|
|
15865
|
+
if (start >= settlement) return 0;
|
|
15866
|
+
const dates = quasiPeriods(first4, start, settlement, frequency2, ctx);
|
|
15867
|
+
const count2 = (a, b) => basis === 0 || basis === 4 ? days360(a, b, basis === 4, ctx) : b - a;
|
|
15868
|
+
let sum2 = 0;
|
|
15869
|
+
for (let i = 0; i + 1 < dates.length; i++) {
|
|
15870
|
+
const [p, q] = [dates[i], dates[i + 1]];
|
|
15871
|
+
const a = count2(Math.max(start, p), Math.min(settlement, q));
|
|
15872
|
+
if (a <= 0) continue;
|
|
15873
|
+
const length = basis === 1 ? q - p : basis === 3 ? 365 / frequency2 : 360 / frequency2;
|
|
15874
|
+
sum2 += a / length;
|
|
15875
|
+
}
|
|
15876
|
+
return par * rate / frequency2 * sum2;
|
|
15877
|
+
}
|
|
15878
|
+
var BOND_ARGS = (name, third, fourth, fifth) => `${name}(settlement, maturity, ${third}, ${fourth}, ${fifth}, frequency, [basis])`;
|
|
15879
|
+
var BOND_FUNCTIONS = [
|
|
15880
|
+
spec(
|
|
15881
|
+
"PRICE",
|
|
15882
|
+
C9,
|
|
15883
|
+
BOND_ARGS("PRICE", "rate", "yld", "redemption"),
|
|
15884
|
+
"The price per 100 face value of a security that pays periodic interest.",
|
|
15885
|
+
6,
|
|
15886
|
+
7,
|
|
15887
|
+
(args, ctx) => {
|
|
15888
|
+
const bond = bondOf(args, ctx, 4, 6);
|
|
15889
|
+
const yld = num2(args[3]);
|
|
15890
|
+
if (bond.rate < 0 || yld < 0 || bond.redemption <= 0) fail(ERR.NUM);
|
|
15891
|
+
return pricePerHundred(bond.facts, bond.rate, yld, bond.redemption, bond.frequency);
|
|
15892
|
+
}
|
|
15893
|
+
),
|
|
15894
|
+
spec(
|
|
15895
|
+
"YIELD",
|
|
15896
|
+
C9,
|
|
15897
|
+
BOND_ARGS("YIELD", "rate", "pr", "redemption"),
|
|
15898
|
+
"The yield of a security that pays periodic interest.",
|
|
15899
|
+
6,
|
|
15900
|
+
7,
|
|
15901
|
+
(args, ctx) => {
|
|
15902
|
+
const bond = bondOf(args, ctx, 4, 6);
|
|
15903
|
+
const price = num2(args[3]);
|
|
15904
|
+
if (bond.rate < 0 || price <= 0 || bond.redemption <= 0) fail(ERR.NUM);
|
|
15905
|
+
const f = (y) => pricePerHundred(bond.facts, bond.rate, y, bond.redemption, bond.frequency) - price;
|
|
15906
|
+
return solve(f, bond.rate || 0.05);
|
|
15907
|
+
}
|
|
15908
|
+
),
|
|
15909
|
+
...["DURATION", "MDURATION"].map(
|
|
15910
|
+
(name) => spec(
|
|
15911
|
+
name,
|
|
15912
|
+
C9,
|
|
15913
|
+
`${name}(settlement, maturity, coupon, yld, frequency, [basis])`,
|
|
15914
|
+
name === "DURATION" ? "The Macaulay duration of a security with periodic interest." : "The modified Macaulay duration of a security.",
|
|
15915
|
+
5,
|
|
15916
|
+
6,
|
|
15917
|
+
(args, ctx) => {
|
|
15918
|
+
const frequency2 = int3(args[4]);
|
|
15919
|
+
const facts = couponFacts(
|
|
15920
|
+
serialArg(args[0]),
|
|
15921
|
+
serialArg(args[1]),
|
|
15922
|
+
frequency2,
|
|
15923
|
+
basisOf(args, 5),
|
|
15924
|
+
ctx
|
|
15925
|
+
);
|
|
15926
|
+
const [rate, yld] = [num2(args[2]), num2(args[3])];
|
|
15927
|
+
if (rate < 0 || yld < 0) fail(ERR.NUM);
|
|
15928
|
+
const macaulay = duration({ facts, rate, frequency: frequency2 }, yld);
|
|
15929
|
+
return name === "DURATION" ? macaulay : macaulay / (1 + yld / frequency2);
|
|
15930
|
+
}
|
|
15931
|
+
)
|
|
15932
|
+
),
|
|
15933
|
+
spec(
|
|
15934
|
+
"ACCRINT",
|
|
15935
|
+
C9,
|
|
15936
|
+
"ACCRINT(issue, first_interest, settlement, rate, par, frequency, [basis], [calc_method])",
|
|
15937
|
+
"The accrued interest of a security that pays periodic interest.",
|
|
15938
|
+
6,
|
|
15939
|
+
8,
|
|
15940
|
+
(args, ctx) => accruedInterest(args, ctx)
|
|
15941
|
+
),
|
|
15942
|
+
spec(
|
|
15943
|
+
"ACCRINTM",
|
|
15944
|
+
C9,
|
|
15945
|
+
"ACCRINTM(issue, settlement, rate, [par], [basis])",
|
|
15946
|
+
"The accrued interest of a security that pays interest at maturity.",
|
|
15947
|
+
3,
|
|
15948
|
+
5,
|
|
15949
|
+
(args, ctx) => {
|
|
15950
|
+
const [issue, settlement] = [serialArg(args[0]), serialArg(args[1])];
|
|
15951
|
+
const [rate, par] = [num2(args[2]), optNum(args, 3, 1e3)];
|
|
15952
|
+
if (rate <= 0 || par <= 0 || issue >= settlement) fail(ERR.NUM);
|
|
15953
|
+
return par * rate * yearFrac(issue, settlement, basisOf(args, 4), ctx);
|
|
15954
|
+
}
|
|
15955
|
+
)
|
|
15956
|
+
];
|
|
15957
|
+
|
|
15731
15958
|
// src/xlsx/formula/functions/depreciation.ts
|
|
15732
|
-
var
|
|
15959
|
+
var C10 = "Financial";
|
|
15960
|
+
function variableDeclining(cost, salvage, life, start, end, factor, noSwitch) {
|
|
15961
|
+
let book = cost;
|
|
15962
|
+
let total2 = 0;
|
|
15963
|
+
for (let period = 1; period - 1 < end; period++) {
|
|
15964
|
+
const declining = book * factor / life;
|
|
15965
|
+
const straight = (book - salvage) / Math.max(life - (period - 1), 1);
|
|
15966
|
+
const wanted = noSwitch ? declining : Math.max(declining, straight);
|
|
15967
|
+
const dep = Math.max(0, Math.min(wanted, book - salvage));
|
|
15968
|
+
const covered = Math.min(end, period) - Math.max(start, period - 1);
|
|
15969
|
+
if (covered > 0) total2 += dep * Math.min(covered, 1);
|
|
15970
|
+
book -= dep;
|
|
15971
|
+
}
|
|
15972
|
+
return total2;
|
|
15973
|
+
}
|
|
15733
15974
|
var DEPRECIATION_FUNCTIONS = [
|
|
15734
15975
|
numeric(
|
|
15735
15976
|
"SLN",
|
|
15736
|
-
|
|
15977
|
+
C10,
|
|
15737
15978
|
"SLN(cost, salvage, life)",
|
|
15738
15979
|
"Straight-line depreciation.",
|
|
15739
15980
|
3,
|
|
@@ -15742,7 +15983,7 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
15742
15983
|
),
|
|
15743
15984
|
numeric(
|
|
15744
15985
|
"SYD",
|
|
15745
|
-
|
|
15986
|
+
C10,
|
|
15746
15987
|
"SYD(cost, salvage, life, per)",
|
|
15747
15988
|
"Sum-of-years' digits depreciation.",
|
|
15748
15989
|
4,
|
|
@@ -15754,7 +15995,7 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
15754
15995
|
),
|
|
15755
15996
|
numeric(
|
|
15756
15997
|
"DDB",
|
|
15757
|
-
|
|
15998
|
+
C10,
|
|
15758
15999
|
"DDB(cost, salvage, life, period, [factor])",
|
|
15759
16000
|
"Double-declining balance depreciation.",
|
|
15760
16001
|
4,
|
|
@@ -15770,9 +16011,33 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
15770
16011
|
return dep;
|
|
15771
16012
|
}
|
|
15772
16013
|
),
|
|
16014
|
+
spec(
|
|
16015
|
+
"VDB",
|
|
16016
|
+
C10,
|
|
16017
|
+
"VDB(cost, salvage, life, start_period, end_period, [factor], [no_switch])",
|
|
16018
|
+
"Depreciation over any span of periods, switching to straight-line when that is larger.",
|
|
16019
|
+
5,
|
|
16020
|
+
7,
|
|
16021
|
+
(args) => {
|
|
16022
|
+
const [cost, salvage, life, start, end] = [0, 1, 2, 3, 4].map((i) => num2(args[i]));
|
|
16023
|
+
const factor = args.length > 5 && args[5] !== null ? num2(args[5]) : 2;
|
|
16024
|
+
const noSwitch = args.length > 6 && args[6] !== null ? bool(args[6]) : false;
|
|
16025
|
+
if ([cost, salvage, life, start, end, factor].some((v) => v === void 0 || Number.isNaN(v)) || cost < 0 || salvage < 0 || life <= 0 || start < 0 || end < start || end > life || factor <= 0)
|
|
16026
|
+
fail(ERR.NUM);
|
|
16027
|
+
return variableDeclining(
|
|
16028
|
+
cost,
|
|
16029
|
+
salvage,
|
|
16030
|
+
life,
|
|
16031
|
+
start,
|
|
16032
|
+
end,
|
|
16033
|
+
factor,
|
|
16034
|
+
noSwitch
|
|
16035
|
+
);
|
|
16036
|
+
}
|
|
16037
|
+
),
|
|
15773
16038
|
numeric(
|
|
15774
16039
|
"DB",
|
|
15775
|
-
|
|
16040
|
+
C10,
|
|
15776
16041
|
"DB(cost, salvage, life, period, [month])",
|
|
15777
16042
|
"Fixed-declining balance depreciation.",
|
|
15778
16043
|
4,
|
|
@@ -15795,7 +16060,7 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
15795
16060
|
),
|
|
15796
16061
|
numeric(
|
|
15797
16062
|
"EFFECT",
|
|
15798
|
-
|
|
16063
|
+
C10,
|
|
15799
16064
|
"EFFECT(nominal_rate, npery)",
|
|
15800
16065
|
"The effective annual interest rate.",
|
|
15801
16066
|
2,
|
|
@@ -15808,7 +16073,7 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
15808
16073
|
),
|
|
15809
16074
|
numeric(
|
|
15810
16075
|
"NOMINAL",
|
|
15811
|
-
|
|
16076
|
+
C10,
|
|
15812
16077
|
"NOMINAL(effect_rate, npery)",
|
|
15813
16078
|
"The nominal annual interest rate.",
|
|
15814
16079
|
2,
|
|
@@ -15821,7 +16086,7 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
15821
16086
|
),
|
|
15822
16087
|
numeric(
|
|
15823
16088
|
"CUMIPMT",
|
|
15824
|
-
|
|
16089
|
+
C10,
|
|
15825
16090
|
"CUMIPMT(rate, nper, pv, start_period, end_period, type)",
|
|
15826
16091
|
"Cumulative interest paid between periods.",
|
|
15827
16092
|
6,
|
|
@@ -15830,7 +16095,7 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
15830
16095
|
),
|
|
15831
16096
|
numeric(
|
|
15832
16097
|
"CUMPRINC",
|
|
15833
|
-
|
|
16098
|
+
C10,
|
|
15834
16099
|
"CUMPRINC(rate, nper, pv, start_period, end_period, type)",
|
|
15835
16100
|
"Cumulative principal paid between periods.",
|
|
15836
16101
|
6,
|
|
@@ -15839,7 +16104,7 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
15839
16104
|
),
|
|
15840
16105
|
numeric(
|
|
15841
16106
|
"ISPMT",
|
|
15842
|
-
|
|
16107
|
+
C10,
|
|
15843
16108
|
"ISPMT(rate, per, nper, pv)",
|
|
15844
16109
|
"Interest paid in a period of a straight-line loan.",
|
|
15845
16110
|
4,
|
|
@@ -15851,7 +16116,7 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
15851
16116
|
),
|
|
15852
16117
|
numeric(
|
|
15853
16118
|
"PDURATION",
|
|
15854
|
-
|
|
16119
|
+
C10,
|
|
15855
16120
|
"PDURATION(rate, pv, fv)",
|
|
15856
16121
|
"Periods required to reach a value.",
|
|
15857
16122
|
3,
|
|
@@ -15863,7 +16128,7 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
15863
16128
|
),
|
|
15864
16129
|
numeric(
|
|
15865
16130
|
"RRI",
|
|
15866
|
-
|
|
16131
|
+
C10,
|
|
15867
16132
|
"RRI(nper, pv, fv)",
|
|
15868
16133
|
"An equivalent interest rate for growth.",
|
|
15869
16134
|
3,
|
|
@@ -15875,7 +16140,7 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
15875
16140
|
),
|
|
15876
16141
|
spec(
|
|
15877
16142
|
"FVSCHEDULE",
|
|
15878
|
-
|
|
16143
|
+
C10,
|
|
15879
16144
|
"FVSCHEDULE(principal, schedule)",
|
|
15880
16145
|
"Future value with a schedule of rates.",
|
|
15881
16146
|
2,
|
|
@@ -15885,7 +16150,7 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
15885
16150
|
),
|
|
15886
16151
|
numeric(
|
|
15887
16152
|
"DOLLARDE",
|
|
15888
|
-
|
|
16153
|
+
C10,
|
|
15889
16154
|
"DOLLARDE(fractional_dollar, fraction)",
|
|
15890
16155
|
"Converts a fractional price to a decimal.",
|
|
15891
16156
|
2,
|
|
@@ -15901,7 +16166,7 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
15901
16166
|
),
|
|
15902
16167
|
numeric(
|
|
15903
16168
|
"DOLLARFR",
|
|
15904
|
-
|
|
16169
|
+
C10,
|
|
15905
16170
|
"DOLLARFR(decimal_dollar, fraction)",
|
|
15906
16171
|
"Converts a decimal price to a fraction.",
|
|
15907
16172
|
2,
|
|
@@ -15917,8 +16182,141 @@ var DEPRECIATION_FUNCTIONS = [
|
|
|
15917
16182
|
)
|
|
15918
16183
|
];
|
|
15919
16184
|
|
|
16185
|
+
// src/xlsx/formula/functions/securities.ts
|
|
16186
|
+
var C11 = "Financial";
|
|
16187
|
+
var basisOf2 = (args, index2) => {
|
|
16188
|
+
const basis = args.length > index2 && args[index2] !== null ? int3(args[index2]) : 0;
|
|
16189
|
+
if (basis < 0 || basis > 4) fail(ERR.NUM);
|
|
16190
|
+
return basis;
|
|
16191
|
+
};
|
|
16192
|
+
function span(args) {
|
|
16193
|
+
const [s, m] = [Math.floor(serialArg(args[0])), Math.floor(serialArg(args[1]))];
|
|
16194
|
+
if (s >= m) fail(ERR.NUM);
|
|
16195
|
+
return { s, m };
|
|
16196
|
+
}
|
|
16197
|
+
var positive = (...values2) => {
|
|
16198
|
+
for (const v of values2) if (!(v > 0)) fail(ERR.NUM);
|
|
16199
|
+
};
|
|
16200
|
+
var discount = (name, description, syntax, fn) => spec(name, C11, syntax, description, 4, 5, (args, ctx) => {
|
|
16201
|
+
const { s, m } = span(args);
|
|
16202
|
+
const [a, b] = [num2(args[2]), num2(args[3])];
|
|
16203
|
+
positive(a, b);
|
|
16204
|
+
return fn(a, b, yearFrac(s, m, basisOf2(args, 4), ctx));
|
|
16205
|
+
});
|
|
16206
|
+
var atMaturity = (name, description, syntax, fn) => spec(name, C11, syntax, description, 5, 6, (args, ctx) => {
|
|
16207
|
+
const { s, m } = span(args);
|
|
16208
|
+
const issue = Math.floor(serialArg(args[2]));
|
|
16209
|
+
const [rate, other] = [num2(args[3]), num2(args[4])];
|
|
16210
|
+
const basis = basisOf2(args, 5);
|
|
16211
|
+
if (issue > s || rate < 0 || other < 0) fail(ERR.NUM);
|
|
16212
|
+
return fn(
|
|
16213
|
+
rate,
|
|
16214
|
+
other,
|
|
16215
|
+
yearFrac(issue, m, basis, ctx),
|
|
16216
|
+
yearFrac(issue, s, basis, ctx),
|
|
16217
|
+
yearFrac(s, m, basis, ctx)
|
|
16218
|
+
);
|
|
16219
|
+
});
|
|
16220
|
+
function billDays(args) {
|
|
16221
|
+
const { s, m } = span(args);
|
|
16222
|
+
const days = m - s;
|
|
16223
|
+
if (days > 365) fail(ERR.NUM);
|
|
16224
|
+
return days;
|
|
16225
|
+
}
|
|
16226
|
+
var SECURITY_FUNCTIONS = [
|
|
16227
|
+
discount(
|
|
16228
|
+
"DISC",
|
|
16229
|
+
"The discount rate of a security.",
|
|
16230
|
+
"DISC(settlement, maturity, pr, redemption, [basis])",
|
|
16231
|
+
(pr, redemption, f) => (redemption - pr) / redemption / f
|
|
16232
|
+
),
|
|
16233
|
+
discount(
|
|
16234
|
+
"PRICEDISC",
|
|
16235
|
+
"The price per 100 face value of a discounted security.",
|
|
16236
|
+
"PRICEDISC(settlement, maturity, discount, redemption, [basis])",
|
|
16237
|
+
(rate, redemption, f) => redemption - rate * redemption * f
|
|
16238
|
+
),
|
|
16239
|
+
discount(
|
|
16240
|
+
"YIELDDISC",
|
|
16241
|
+
"The annual yield of a discounted security.",
|
|
16242
|
+
"YIELDDISC(settlement, maturity, pr, redemption, [basis])",
|
|
16243
|
+
(pr, redemption, f) => (redemption - pr) / pr / f
|
|
16244
|
+
),
|
|
16245
|
+
discount(
|
|
16246
|
+
"INTRATE",
|
|
16247
|
+
"The interest rate of a fully invested security.",
|
|
16248
|
+
"INTRATE(settlement, maturity, investment, redemption, [basis])",
|
|
16249
|
+
(investment, redemption, f) => (redemption - investment) / investment / f
|
|
16250
|
+
),
|
|
16251
|
+
discount(
|
|
16252
|
+
"RECEIVED",
|
|
16253
|
+
"The amount received at maturity for a fully invested security.",
|
|
16254
|
+
"RECEIVED(settlement, maturity, investment, discount, [basis])",
|
|
16255
|
+
(investment, rate, f) => investment / (1 - rate * f)
|
|
16256
|
+
),
|
|
16257
|
+
atMaturity(
|
|
16258
|
+
"PRICEMAT",
|
|
16259
|
+
"The price per 100 face value of a security that pays interest at maturity.",
|
|
16260
|
+
"PRICEMAT(settlement, maturity, issue, rate, yld, [basis])",
|
|
16261
|
+
(rate, yld, dim, a, dsm) => (100 + dim * rate * 100) / (1 + dsm * yld) - a * rate * 100
|
|
16262
|
+
),
|
|
16263
|
+
atMaturity(
|
|
16264
|
+
"YIELDMAT",
|
|
16265
|
+
"The annual yield of a security that pays interest at maturity.",
|
|
16266
|
+
"YIELDMAT(settlement, maturity, issue, rate, pr, [basis])",
|
|
16267
|
+
(rate, price, dim, a, dsm) => (1 + dim * rate - (price / 100 + a * rate)) / (price / 100 + a * rate) / dsm
|
|
16268
|
+
),
|
|
16269
|
+
spec(
|
|
16270
|
+
"TBILLPRICE",
|
|
16271
|
+
C11,
|
|
16272
|
+
"TBILLPRICE(settlement, maturity, discount)",
|
|
16273
|
+
"The price per 100 face value of a Treasury bill.",
|
|
16274
|
+
3,
|
|
16275
|
+
3,
|
|
16276
|
+
(args) => {
|
|
16277
|
+
const days = billDays(args);
|
|
16278
|
+
const rate = num2(args[2]);
|
|
16279
|
+
positive(rate);
|
|
16280
|
+
const price = 100 * (1 - rate * days / 360);
|
|
16281
|
+
return price > 0 ? price : fail(ERR.NUM);
|
|
16282
|
+
}
|
|
16283
|
+
),
|
|
16284
|
+
spec(
|
|
16285
|
+
"TBILLYIELD",
|
|
16286
|
+
C11,
|
|
16287
|
+
"TBILLYIELD(settlement, maturity, pr)",
|
|
16288
|
+
"The yield of a Treasury bill.",
|
|
16289
|
+
3,
|
|
16290
|
+
3,
|
|
16291
|
+
(args) => {
|
|
16292
|
+
const days = billDays(args);
|
|
16293
|
+
const price = num2(args[2]);
|
|
16294
|
+
positive(price);
|
|
16295
|
+
return (100 - price) / price * (360 / days);
|
|
16296
|
+
}
|
|
16297
|
+
),
|
|
16298
|
+
spec(
|
|
16299
|
+
"TBILLEQ",
|
|
16300
|
+
C11,
|
|
16301
|
+
"TBILLEQ(settlement, maturity, discount)",
|
|
16302
|
+
"The bond-equivalent yield of a Treasury bill.",
|
|
16303
|
+
3,
|
|
16304
|
+
3,
|
|
16305
|
+
(args) => {
|
|
16306
|
+
const days = billDays(args);
|
|
16307
|
+
const rate = num2(args[2]);
|
|
16308
|
+
positive(rate);
|
|
16309
|
+
if (days <= 182) return 365 * rate / (360 - rate * days);
|
|
16310
|
+
const price = 100 - rate * 100 * (days / 360);
|
|
16311
|
+
const t = days / 365;
|
|
16312
|
+
const root = Math.sqrt(t * t - (2 * t - 1) * (1 - 100 / price));
|
|
16313
|
+
return (-t + root) / (t - 0.5);
|
|
16314
|
+
}
|
|
16315
|
+
)
|
|
16316
|
+
];
|
|
16317
|
+
|
|
15920
16318
|
// src/xlsx/formula/functions/financial.ts
|
|
15921
|
-
var
|
|
16319
|
+
var C12 = "Financial";
|
|
15922
16320
|
var npv = (rate, values2) => values2.reduce((acc, v, i) => acc + v / Math.pow(1 + rate, i + 1), 0);
|
|
15923
16321
|
function datedFlows(ctx, args) {
|
|
15924
16322
|
const values2 = collectNumbers(ctx, [args[0] ?? null]);
|
|
@@ -15934,9 +16332,12 @@ var xnpv = (rate, values2, dates) => values2.reduce(
|
|
|
15934
16332
|
);
|
|
15935
16333
|
var FINANCIAL_FUNCTIONS = [
|
|
15936
16334
|
...DEPRECIATION_FUNCTIONS,
|
|
16335
|
+
...COUPON_FUNCTIONS,
|
|
16336
|
+
...BOND_FUNCTIONS,
|
|
16337
|
+
...SECURITY_FUNCTIONS,
|
|
15937
16338
|
numeric(
|
|
15938
16339
|
"PMT",
|
|
15939
|
-
|
|
16340
|
+
C12,
|
|
15940
16341
|
"PMT(rate, nper, pv, [fv], [type])",
|
|
15941
16342
|
"The payment for a loan.",
|
|
15942
16343
|
3,
|
|
@@ -15945,7 +16346,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
15945
16346
|
),
|
|
15946
16347
|
numeric(
|
|
15947
16348
|
"FV",
|
|
15948
|
-
|
|
16349
|
+
C12,
|
|
15949
16350
|
"FV(rate, nper, pmt, [pv], [type])",
|
|
15950
16351
|
"The future value of an investment.",
|
|
15951
16352
|
3,
|
|
@@ -15954,7 +16355,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
15954
16355
|
),
|
|
15955
16356
|
numeric(
|
|
15956
16357
|
"PV",
|
|
15957
|
-
|
|
16358
|
+
C12,
|
|
15958
16359
|
"PV(rate, nper, pmt, [fv], [type])",
|
|
15959
16360
|
"The present value of an investment.",
|
|
15960
16361
|
3,
|
|
@@ -15963,7 +16364,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
15963
16364
|
),
|
|
15964
16365
|
numeric(
|
|
15965
16366
|
"NPER",
|
|
15966
|
-
|
|
16367
|
+
C12,
|
|
15967
16368
|
"NPER(rate, pmt, pv, [fv], [type])",
|
|
15968
16369
|
"The number of periods for an investment.",
|
|
15969
16370
|
3,
|
|
@@ -15980,7 +16381,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
15980
16381
|
),
|
|
15981
16382
|
numeric(
|
|
15982
16383
|
"IPMT",
|
|
15983
|
-
|
|
16384
|
+
C12,
|
|
15984
16385
|
"IPMT(rate, per, nper, pv, [fv], [type])",
|
|
15985
16386
|
"The interest part of a payment.",
|
|
15986
16387
|
4,
|
|
@@ -15989,7 +16390,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
15989
16390
|
),
|
|
15990
16391
|
numeric(
|
|
15991
16392
|
"PPMT",
|
|
15992
|
-
|
|
16393
|
+
C12,
|
|
15993
16394
|
"PPMT(rate, per, nper, pv, [fv], [type])",
|
|
15994
16395
|
"The principal part of a payment.",
|
|
15995
16396
|
4,
|
|
@@ -15998,7 +16399,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
15998
16399
|
),
|
|
15999
16400
|
numeric(
|
|
16000
16401
|
"RATE",
|
|
16001
|
-
|
|
16402
|
+
C12,
|
|
16002
16403
|
"RATE(nper, pmt, pv, [fv], [type], [guess])",
|
|
16003
16404
|
"The interest rate per period.",
|
|
16004
16405
|
3,
|
|
@@ -16011,7 +16412,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
16011
16412
|
),
|
|
16012
16413
|
spec(
|
|
16013
16414
|
"NPV",
|
|
16014
|
-
|
|
16415
|
+
C12,
|
|
16015
16416
|
"NPV(rate, value1, [value2], ...)",
|
|
16016
16417
|
"The net present value of cash flows.",
|
|
16017
16418
|
2,
|
|
@@ -16021,7 +16422,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
16021
16422
|
),
|
|
16022
16423
|
spec(
|
|
16023
16424
|
"IRR",
|
|
16024
|
-
|
|
16425
|
+
C12,
|
|
16025
16426
|
"IRR(values, [guess])",
|
|
16026
16427
|
"The internal rate of return.",
|
|
16027
16428
|
1,
|
|
@@ -16038,7 +16439,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
16038
16439
|
),
|
|
16039
16440
|
spec(
|
|
16040
16441
|
"XNPV",
|
|
16041
|
-
|
|
16442
|
+
C12,
|
|
16042
16443
|
"XNPV(rate, values, dates)",
|
|
16043
16444
|
"The net present value of dated cash flows.",
|
|
16044
16445
|
3,
|
|
@@ -16051,7 +16452,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
16051
16452
|
),
|
|
16052
16453
|
spec(
|
|
16053
16454
|
"XIRR",
|
|
16054
|
-
|
|
16455
|
+
C12,
|
|
16055
16456
|
"XIRR(values, dates, [guess])",
|
|
16056
16457
|
"The internal rate of return of dated cash flows.",
|
|
16057
16458
|
2,
|
|
@@ -16065,7 +16466,7 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
16065
16466
|
),
|
|
16066
16467
|
spec(
|
|
16067
16468
|
"MIRR",
|
|
16068
|
-
|
|
16469
|
+
C12,
|
|
16069
16470
|
"MIRR(values, finance_rate, reinvest_rate)",
|
|
16070
16471
|
"The modified internal rate of return.",
|
|
16071
16472
|
3,
|
|
@@ -16075,9 +16476,9 @@ var FINANCIAL_FUNCTIONS = [
|
|
|
16075
16476
|
const finance = num2(args[1]);
|
|
16076
16477
|
const reinvest = num2(args[2]);
|
|
16077
16478
|
const n = values2.length;
|
|
16078
|
-
const
|
|
16479
|
+
const positive4 = values2.map((v) => v > 0 ? v : 0);
|
|
16079
16480
|
const negative = values2.map((v) => v < 0 ? v : 0);
|
|
16080
|
-
const fvPos =
|
|
16481
|
+
const fvPos = positive4.reduce((acc, v, i) => acc + v * Math.pow(1 + reinvest, n - 1 - i), 0);
|
|
16081
16482
|
const pvNeg = negative.reduce((acc, v, i) => acc + v / Math.pow(1 + finance, i), 0);
|
|
16082
16483
|
if (fvPos === 0 || pvNeg === 0) fail(ERR.DIV0);
|
|
16083
16484
|
return Math.pow(-fvPos / pvNeg, 1 / (n - 1)) - 1;
|
|
@@ -16282,7 +16683,7 @@ function implicitIntersection(value, frame) {
|
|
|
16282
16683
|
}
|
|
16283
16684
|
|
|
16284
16685
|
// src/xlsx/formula/functions/info.ts
|
|
16285
|
-
var
|
|
16686
|
+
var C13 = "Information";
|
|
16286
16687
|
var ERROR_NUMBERS = {
|
|
16287
16688
|
"#NULL!": 1,
|
|
16288
16689
|
"#DIV/0!": 2,
|
|
@@ -16295,7 +16696,7 @@ var ERROR_NUMBERS = {
|
|
|
16295
16696
|
"#SPILL!": 9,
|
|
16296
16697
|
"#CALC!": 14
|
|
16297
16698
|
};
|
|
16298
|
-
var is = (name, syntax, description, test) => spec(name,
|
|
16699
|
+
var is = (name, syntax, description, test) => spec(name, C13, syntax, description, 1, 1, (args) => test(scalar(args[0])));
|
|
16299
16700
|
var parity = (v, odd) => {
|
|
16300
16701
|
if (isError(v)) fail(v);
|
|
16301
16702
|
if (typeof v === "boolean") fail(ERR.VALUE);
|
|
@@ -16332,7 +16733,7 @@ var INFO_FUNCTIONS = [
|
|
|
16332
16733
|
is("ISODD", "ISODD(number)", "TRUE for odd numbers.", (v) => parity(v, true)),
|
|
16333
16734
|
spec(
|
|
16334
16735
|
"ISREF",
|
|
16335
|
-
|
|
16736
|
+
C13,
|
|
16336
16737
|
"ISREF(value)",
|
|
16337
16738
|
"TRUE for references.",
|
|
16338
16739
|
1,
|
|
@@ -16342,7 +16743,7 @@ var INFO_FUNCTIONS = [
|
|
|
16342
16743
|
),
|
|
16343
16744
|
spec(
|
|
16344
16745
|
"ISFORMULA",
|
|
16345
|
-
|
|
16746
|
+
C13,
|
|
16346
16747
|
"ISFORMULA(reference)",
|
|
16347
16748
|
"TRUE when a cell holds a formula.",
|
|
16348
16749
|
1,
|
|
@@ -16356,17 +16757,17 @@ var INFO_FUNCTIONS = [
|
|
|
16356
16757
|
},
|
|
16357
16758
|
["any"]
|
|
16358
16759
|
),
|
|
16359
|
-
spec("N",
|
|
16760
|
+
spec("N", C13, "N(value)", "A value converted to a number (text is 0).", 1, 1, (args) => {
|
|
16360
16761
|
const v = scalar(args[0]);
|
|
16361
16762
|
if (isError(v)) return v;
|
|
16362
16763
|
if (typeof v === "number") return v;
|
|
16363
16764
|
if (typeof v === "boolean") return v ? 1 : 0;
|
|
16364
16765
|
return 0;
|
|
16365
16766
|
}),
|
|
16366
|
-
spec("NA",
|
|
16767
|
+
spec("NA", C13, "NA()", "The #N/A error value.", 0, 0, () => ERR.NA),
|
|
16367
16768
|
spec(
|
|
16368
16769
|
"TYPE",
|
|
16369
|
-
|
|
16770
|
+
C13,
|
|
16370
16771
|
"TYPE(value)",
|
|
16371
16772
|
"The type of a value: 1 number, 2 text, 4 logical, 16 error, 64 array.",
|
|
16372
16773
|
1,
|
|
@@ -16378,13 +16779,13 @@ var INFO_FUNCTIONS = [
|
|
|
16378
16779
|
},
|
|
16379
16780
|
["any"]
|
|
16380
16781
|
),
|
|
16381
|
-
spec("ERROR.TYPE",
|
|
16782
|
+
spec("ERROR.TYPE", C13, "ERROR.TYPE(error_val)", "The number of an error value.", 1, 1, (args) => {
|
|
16382
16783
|
const v = scalar(args[0]);
|
|
16383
16784
|
return isError(v) ? ERROR_NUMBERS[v.error] ?? ERR.NA : ERR.NA;
|
|
16384
16785
|
}),
|
|
16385
16786
|
spec(
|
|
16386
16787
|
"SHEET",
|
|
16387
|
-
|
|
16788
|
+
C13,
|
|
16388
16789
|
"SHEET([value])",
|
|
16389
16790
|
"The sheet number of a reference or sheet name.",
|
|
16390
16791
|
0,
|
|
@@ -16400,7 +16801,7 @@ var INFO_FUNCTIONS = [
|
|
|
16400
16801
|
),
|
|
16401
16802
|
spec(
|
|
16402
16803
|
"SHEETS",
|
|
16403
|
-
|
|
16804
|
+
C13,
|
|
16404
16805
|
"SHEETS([reference])",
|
|
16405
16806
|
"The number of sheets in a reference (or the workbook).",
|
|
16406
16807
|
0,
|
|
@@ -16415,7 +16816,7 @@ var INFO_FUNCTIONS = [
|
|
|
16415
16816
|
),
|
|
16416
16817
|
spec(
|
|
16417
16818
|
"CELL",
|
|
16418
|
-
|
|
16819
|
+
C13,
|
|
16419
16820
|
"CELL(info_type, [reference])",
|
|
16420
16821
|
"Information about a cell (address, row, col, contents, type, filename, sheet).",
|
|
16421
16822
|
1,
|
|
@@ -16590,7 +16991,7 @@ function broadcast1(a, fn) {
|
|
|
16590
16991
|
}
|
|
16591
16992
|
|
|
16592
16993
|
// src/xlsx/formula/functions/lambda.ts
|
|
16593
|
-
var
|
|
16994
|
+
var C14 = "Logical";
|
|
16594
16995
|
function lambdaArg(value) {
|
|
16595
16996
|
if (!(value instanceof LambdaValue)) fail(ERR.VALUE);
|
|
16596
16997
|
return value;
|
|
@@ -16607,7 +17008,7 @@ function element(ctx, value) {
|
|
|
16607
17008
|
var LAMBDA_HELPERS = [
|
|
16608
17009
|
spec(
|
|
16609
17010
|
"MAP",
|
|
16610
|
-
|
|
17011
|
+
C14,
|
|
16611
17012
|
"MAP(array1, ..., lambda)",
|
|
16612
17013
|
"Applies a LAMBDA to each value of arrays.",
|
|
16613
17014
|
2,
|
|
@@ -16633,7 +17034,7 @@ var LAMBDA_HELPERS = [
|
|
|
16633
17034
|
),
|
|
16634
17035
|
spec(
|
|
16635
17036
|
"REDUCE",
|
|
16636
|
-
|
|
17037
|
+
C14,
|
|
16637
17038
|
"REDUCE([initial_value], array, lambda)",
|
|
16638
17039
|
"Reduces an array to an accumulated value.",
|
|
16639
17040
|
2,
|
|
@@ -16649,7 +17050,7 @@ var LAMBDA_HELPERS = [
|
|
|
16649
17050
|
),
|
|
16650
17051
|
spec(
|
|
16651
17052
|
"SCAN",
|
|
16652
|
-
|
|
17053
|
+
C14,
|
|
16653
17054
|
"SCAN([initial_value], array, lambda)",
|
|
16654
17055
|
"The intermediate values of a reduction, as an array.",
|
|
16655
17056
|
2,
|
|
@@ -16667,7 +17068,7 @@ var LAMBDA_HELPERS = [
|
|
|
16667
17068
|
),
|
|
16668
17069
|
spec(
|
|
16669
17070
|
"BYROW",
|
|
16670
|
-
|
|
17071
|
+
C14,
|
|
16671
17072
|
"BYROW(array, lambda)",
|
|
16672
17073
|
"Applies a LAMBDA to each row, returning a column.",
|
|
16673
17074
|
2,
|
|
@@ -16683,7 +17084,7 @@ var LAMBDA_HELPERS = [
|
|
|
16683
17084
|
),
|
|
16684
17085
|
spec(
|
|
16685
17086
|
"BYCOL",
|
|
16686
|
-
|
|
17087
|
+
C14,
|
|
16687
17088
|
"BYCOL(array, lambda)",
|
|
16688
17089
|
"Applies a LAMBDA to each column, returning a row.",
|
|
16689
17090
|
2,
|
|
@@ -16702,7 +17103,7 @@ var LAMBDA_HELPERS = [
|
|
|
16702
17103
|
),
|
|
16703
17104
|
spec(
|
|
16704
17105
|
"MAKEARRAY",
|
|
16705
|
-
|
|
17106
|
+
C14,
|
|
16706
17107
|
"MAKEARRAY(rows, columns, lambda)",
|
|
16707
17108
|
"An array built by calling a LAMBDA for each position.",
|
|
16708
17109
|
3,
|
|
@@ -16719,7 +17120,7 @@ var LAMBDA_HELPERS = [
|
|
|
16719
17120
|
];
|
|
16720
17121
|
|
|
16721
17122
|
// src/xlsx/formula/functions/logical.ts
|
|
16722
|
-
var
|
|
17123
|
+
var C15 = "Logical";
|
|
16723
17124
|
function deref(ctx, value) {
|
|
16724
17125
|
if (value instanceof RefValue) {
|
|
16725
17126
|
if (value.isCell()) {
|
|
@@ -16789,7 +17190,7 @@ function logicalValues(ctx, args) {
|
|
|
16789
17190
|
if (out.length === 0) fail(ERR.VALUE);
|
|
16790
17191
|
return out;
|
|
16791
17192
|
}
|
|
16792
|
-
var lazySpec = (name, syntax, description, minArgs, maxArgs, lazy, category =
|
|
17193
|
+
var lazySpec = (name, syntax, description, minArgs, maxArgs, lazy, category = C15) => ({ name, category, syntax, description, minArgs, maxArgs, lazy });
|
|
16793
17194
|
function localName(arg) {
|
|
16794
17195
|
const node = arg?.node;
|
|
16795
17196
|
if (!node || node.type !== "name" || node.prefix) fail(ERR.VALUE);
|
|
@@ -16883,7 +17284,7 @@ var LOGICAL_FUNCTIONS = [
|
|
|
16883
17284
|
),
|
|
16884
17285
|
{
|
|
16885
17286
|
name: "NOT",
|
|
16886
|
-
category:
|
|
17287
|
+
category: C15,
|
|
16887
17288
|
syntax: "NOT(logical)",
|
|
16888
17289
|
description: "Reverses a logical value.",
|
|
16889
17290
|
minArgs: 1,
|
|
@@ -16892,7 +17293,7 @@ var LOGICAL_FUNCTIONS = [
|
|
|
16892
17293
|
},
|
|
16893
17294
|
{
|
|
16894
17295
|
name: "TRUE",
|
|
16895
|
-
category:
|
|
17296
|
+
category: C15,
|
|
16896
17297
|
syntax: "TRUE()",
|
|
16897
17298
|
description: "The logical value TRUE.",
|
|
16898
17299
|
minArgs: 0,
|
|
@@ -16901,7 +17302,7 @@ var LOGICAL_FUNCTIONS = [
|
|
|
16901
17302
|
},
|
|
16902
17303
|
{
|
|
16903
17304
|
name: "FALSE",
|
|
16904
|
-
category:
|
|
17305
|
+
category: C15,
|
|
16905
17306
|
syntax: "FALSE()",
|
|
16906
17307
|
description: "The logical value FALSE.",
|
|
16907
17308
|
minArgs: 0,
|
|
@@ -17099,7 +17500,7 @@ function xsearch(vector, lookup2, matchMode, searchMode) {
|
|
|
17099
17500
|
}
|
|
17100
17501
|
|
|
17101
17502
|
// src/xlsx/formula/functions/reference.ts
|
|
17102
|
-
var
|
|
17503
|
+
var C16 = "Lookup & Reference";
|
|
17103
17504
|
function refArg(value) {
|
|
17104
17505
|
if (value instanceof RefValue) return value;
|
|
17105
17506
|
if (isError(value)) fail(value);
|
|
@@ -17188,7 +17589,7 @@ function rowsOrCols(value, ctx, axis) {
|
|
|
17188
17589
|
var REFERENCE_FUNCTIONS = [
|
|
17189
17590
|
spec(
|
|
17190
17591
|
"OFFSET",
|
|
17191
|
-
|
|
17592
|
+
C16,
|
|
17192
17593
|
"OFFSET(reference, rows, cols, [height], [width])",
|
|
17193
17594
|
"A reference offset from a starting reference.",
|
|
17194
17595
|
3,
|
|
@@ -17199,7 +17600,7 @@ var REFERENCE_FUNCTIONS = [
|
|
|
17199
17600
|
),
|
|
17200
17601
|
spec(
|
|
17201
17602
|
"INDIRECT",
|
|
17202
|
-
|
|
17603
|
+
C16,
|
|
17203
17604
|
"INDIRECT(ref_text, [a1])",
|
|
17204
17605
|
"The reference named by a text.",
|
|
17205
17606
|
1,
|
|
@@ -17215,7 +17616,7 @@ var REFERENCE_FUNCTIONS = [
|
|
|
17215
17616
|
),
|
|
17216
17617
|
spec(
|
|
17217
17618
|
"ROW",
|
|
17218
|
-
|
|
17619
|
+
C16,
|
|
17219
17620
|
"ROW([reference])",
|
|
17220
17621
|
"The row number of a reference.",
|
|
17221
17622
|
0,
|
|
@@ -17225,7 +17626,7 @@ var REFERENCE_FUNCTIONS = [
|
|
|
17225
17626
|
),
|
|
17226
17627
|
spec(
|
|
17227
17628
|
"COLUMN",
|
|
17228
|
-
|
|
17629
|
+
C16,
|
|
17229
17630
|
"COLUMN([reference])",
|
|
17230
17631
|
"The column number of a reference.",
|
|
17231
17632
|
0,
|
|
@@ -17235,7 +17636,7 @@ var REFERENCE_FUNCTIONS = [
|
|
|
17235
17636
|
),
|
|
17236
17637
|
spec(
|
|
17237
17638
|
"ROWS",
|
|
17238
|
-
|
|
17639
|
+
C16,
|
|
17239
17640
|
"ROWS(array)",
|
|
17240
17641
|
"The number of rows in a reference or array.",
|
|
17241
17642
|
1,
|
|
@@ -17248,7 +17649,7 @@ var REFERENCE_FUNCTIONS = [
|
|
|
17248
17649
|
),
|
|
17249
17650
|
spec(
|
|
17250
17651
|
"COLUMNS",
|
|
17251
|
-
|
|
17652
|
+
C16,
|
|
17252
17653
|
"COLUMNS(array)",
|
|
17253
17654
|
"The number of columns in a reference or array.",
|
|
17254
17655
|
1,
|
|
@@ -17261,7 +17662,7 @@ var REFERENCE_FUNCTIONS = [
|
|
|
17261
17662
|
),
|
|
17262
17663
|
spec(
|
|
17263
17664
|
"AREAS",
|
|
17264
|
-
|
|
17665
|
+
C16,
|
|
17265
17666
|
"AREAS(reference)",
|
|
17266
17667
|
"The number of areas in a reference.",
|
|
17267
17668
|
1,
|
|
@@ -17271,7 +17672,7 @@ var REFERENCE_FUNCTIONS = [
|
|
|
17271
17672
|
),
|
|
17272
17673
|
spec(
|
|
17273
17674
|
"ADDRESS",
|
|
17274
|
-
|
|
17675
|
+
C16,
|
|
17275
17676
|
"ADDRESS(row_num, column_num, [abs_num], [a1], [sheet_text])",
|
|
17276
17677
|
"A cell address as text.",
|
|
17277
17678
|
2,
|
|
@@ -17280,7 +17681,7 @@ var REFERENCE_FUNCTIONS = [
|
|
|
17280
17681
|
),
|
|
17281
17682
|
spec(
|
|
17282
17683
|
"HYPERLINK",
|
|
17283
|
-
|
|
17684
|
+
C16,
|
|
17284
17685
|
"HYPERLINK(link_location, [friendly_name])",
|
|
17285
17686
|
"A link; the cell shows the friendly name.",
|
|
17286
17687
|
1,
|
|
@@ -17289,7 +17690,7 @@ var REFERENCE_FUNCTIONS = [
|
|
|
17289
17690
|
),
|
|
17290
17691
|
spec(
|
|
17291
17692
|
"ANCHORARRAY",
|
|
17292
|
-
|
|
17693
|
+
C16,
|
|
17293
17694
|
"ANCHORARRAY(reference)",
|
|
17294
17695
|
"The spill range of a dynamic array formula (A1#).",
|
|
17295
17696
|
1,
|
|
@@ -17309,7 +17710,7 @@ var REFERENCE_FUNCTIONS = [
|
|
|
17309
17710
|
),
|
|
17310
17711
|
spec(
|
|
17311
17712
|
"SINGLE",
|
|
17312
|
-
|
|
17713
|
+
C16,
|
|
17313
17714
|
"SINGLE(value)",
|
|
17314
17715
|
"Implicit intersection (the @ operator).",
|
|
17315
17716
|
1,
|
|
@@ -17319,7 +17720,7 @@ var REFERENCE_FUNCTIONS = [
|
|
|
17319
17720
|
),
|
|
17320
17721
|
spec(
|
|
17321
17722
|
"FORMULATEXT",
|
|
17322
|
-
|
|
17723
|
+
C16,
|
|
17323
17724
|
"FORMULATEXT(reference)",
|
|
17324
17725
|
"The formula of a cell as text.",
|
|
17325
17726
|
1,
|
|
@@ -17339,7 +17740,7 @@ var REFERENCE_FUNCTIONS = [
|
|
|
17339
17740
|
];
|
|
17340
17741
|
|
|
17341
17742
|
// src/xlsx/formula/functions/lookup.ts
|
|
17342
|
-
var
|
|
17743
|
+
var C17 = "Lookup & Reference";
|
|
17343
17744
|
function cellOf(value, row2, col) {
|
|
17344
17745
|
if (value instanceof RefValue) {
|
|
17345
17746
|
const area = value.areas[0];
|
|
@@ -17466,7 +17867,7 @@ var LOOKUP_FUNCTIONS = [
|
|
|
17466
17867
|
...REFERENCE_FUNCTIONS,
|
|
17467
17868
|
spec(
|
|
17468
17869
|
"VLOOKUP",
|
|
17469
|
-
|
|
17870
|
+
C17,
|
|
17470
17871
|
"VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup])",
|
|
17471
17872
|
"Looks up a value in the first column of a table.",
|
|
17472
17873
|
3,
|
|
@@ -17476,7 +17877,7 @@ var LOOKUP_FUNCTIONS = [
|
|
|
17476
17877
|
),
|
|
17477
17878
|
spec(
|
|
17478
17879
|
"HLOOKUP",
|
|
17479
|
-
|
|
17880
|
+
C17,
|
|
17480
17881
|
"HLOOKUP(lookup_value, table_array, row_index_num, [range_lookup])",
|
|
17481
17882
|
"Looks up a value in the first row of a table.",
|
|
17482
17883
|
3,
|
|
@@ -17486,7 +17887,7 @@ var LOOKUP_FUNCTIONS = [
|
|
|
17486
17887
|
),
|
|
17487
17888
|
spec(
|
|
17488
17889
|
"LOOKUP",
|
|
17489
|
-
|
|
17890
|
+
C17,
|
|
17490
17891
|
"LOOKUP(lookup_value, lookup_vector, [result_vector])",
|
|
17491
17892
|
"Looks up a value in a sorted vector or array.",
|
|
17492
17893
|
2,
|
|
@@ -17496,7 +17897,7 @@ var LOOKUP_FUNCTIONS = [
|
|
|
17496
17897
|
),
|
|
17497
17898
|
spec(
|
|
17498
17899
|
"MATCH",
|
|
17499
|
-
|
|
17900
|
+
C17,
|
|
17500
17901
|
"MATCH(lookup_value, lookup_array, [match_type])",
|
|
17501
17902
|
"The position of a value in a range.",
|
|
17502
17903
|
2,
|
|
@@ -17506,7 +17907,7 @@ var LOOKUP_FUNCTIONS = [
|
|
|
17506
17907
|
),
|
|
17507
17908
|
spec(
|
|
17508
17909
|
"XMATCH",
|
|
17509
|
-
|
|
17910
|
+
C17,
|
|
17510
17911
|
"XMATCH(lookup_value, lookup_array, [match_mode], [search_mode])",
|
|
17511
17912
|
"The position of a value with flexible matching.",
|
|
17512
17913
|
2,
|
|
@@ -17526,7 +17927,7 @@ var LOOKUP_FUNCTIONS = [
|
|
|
17526
17927
|
),
|
|
17527
17928
|
spec(
|
|
17528
17929
|
"XLOOKUP",
|
|
17529
|
-
|
|
17930
|
+
C17,
|
|
17530
17931
|
"XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode])",
|
|
17531
17932
|
"Searches a range and returns the matching item from another.",
|
|
17532
17933
|
3,
|
|
@@ -17536,7 +17937,7 @@ var LOOKUP_FUNCTIONS = [
|
|
|
17536
17937
|
),
|
|
17537
17938
|
spec(
|
|
17538
17939
|
"INDEX",
|
|
17539
|
-
|
|
17940
|
+
C17,
|
|
17540
17941
|
"INDEX(array, row_num, [column_num], [area_num])",
|
|
17541
17942
|
"The value or reference at a position.",
|
|
17542
17943
|
1,
|
|
@@ -17546,7 +17947,7 @@ var LOOKUP_FUNCTIONS = [
|
|
|
17546
17947
|
),
|
|
17547
17948
|
spec(
|
|
17548
17949
|
"CHOOSE",
|
|
17549
|
-
|
|
17950
|
+
C17,
|
|
17550
17951
|
"CHOOSE(index_num, value1, [value2], ...)",
|
|
17551
17952
|
"Chooses a value from a list by index.",
|
|
17552
17953
|
2,
|
|
@@ -17750,7 +18151,7 @@ function liftCriteria(ctx, pairs, fn) {
|
|
|
17750
18151
|
}
|
|
17751
18152
|
|
|
17752
18153
|
// src/xlsx/formula/functions/math-sum.ts
|
|
17753
|
-
var
|
|
18154
|
+
var C18 = "Math & Trig";
|
|
17754
18155
|
var numbersOf = (values2) => values2.filter((v) => typeof v === "number");
|
|
17755
18156
|
function sumProduct(ctx, args) {
|
|
17756
18157
|
const matrices = args.map((a) => ctx.toMatrix(a));
|
|
@@ -17855,7 +18256,7 @@ function aggregate(code, values2, k) {
|
|
|
17855
18256
|
var SUM_FUNCTIONS = [
|
|
17856
18257
|
spec(
|
|
17857
18258
|
"SUM",
|
|
17858
|
-
|
|
18259
|
+
C18,
|
|
17859
18260
|
"SUM(number1, [number2], ...)",
|
|
17860
18261
|
"Adds its arguments.",
|
|
17861
18262
|
0,
|
|
@@ -17865,7 +18266,7 @@ var SUM_FUNCTIONS = [
|
|
|
17865
18266
|
),
|
|
17866
18267
|
spec(
|
|
17867
18268
|
"PRODUCT",
|
|
17868
|
-
|
|
18269
|
+
C18,
|
|
17869
18270
|
"PRODUCT(number1, [number2], ...)",
|
|
17870
18271
|
"Multiplies its arguments.",
|
|
17871
18272
|
1,
|
|
@@ -17878,7 +18279,7 @@ var SUM_FUNCTIONS = [
|
|
|
17878
18279
|
),
|
|
17879
18280
|
spec(
|
|
17880
18281
|
"SUMSQ",
|
|
17881
|
-
|
|
18282
|
+
C18,
|
|
17882
18283
|
"SUMSQ(number1, [number2], ...)",
|
|
17883
18284
|
"The sum of the squares of the arguments.",
|
|
17884
18285
|
1,
|
|
@@ -17888,7 +18289,7 @@ var SUM_FUNCTIONS = [
|
|
|
17888
18289
|
),
|
|
17889
18290
|
spec(
|
|
17890
18291
|
"SUMPRODUCT",
|
|
17891
|
-
|
|
18292
|
+
C18,
|
|
17892
18293
|
"SUMPRODUCT(array1, [array2], ...)",
|
|
17893
18294
|
"The sum of the products of corresponding array elements.",
|
|
17894
18295
|
1,
|
|
@@ -17898,7 +18299,7 @@ var SUM_FUNCTIONS = [
|
|
|
17898
18299
|
),
|
|
17899
18300
|
spec(
|
|
17900
18301
|
"SUMX2MY2",
|
|
17901
|
-
|
|
18302
|
+
C18,
|
|
17902
18303
|
"SUMX2MY2(array_x, array_y)",
|
|
17903
18304
|
"Sum of the differences of squares.",
|
|
17904
18305
|
2,
|
|
@@ -17908,7 +18309,7 @@ var SUM_FUNCTIONS = [
|
|
|
17908
18309
|
),
|
|
17909
18310
|
spec(
|
|
17910
18311
|
"SUMX2PY2",
|
|
17911
|
-
|
|
18312
|
+
C18,
|
|
17912
18313
|
"SUMX2PY2(array_x, array_y)",
|
|
17913
18314
|
"Sum of the sums of squares.",
|
|
17914
18315
|
2,
|
|
@@ -17918,7 +18319,7 @@ var SUM_FUNCTIONS = [
|
|
|
17918
18319
|
),
|
|
17919
18320
|
spec(
|
|
17920
18321
|
"SUMXMY2",
|
|
17921
|
-
|
|
18322
|
+
C18,
|
|
17922
18323
|
"SUMXMY2(array_x, array_y)",
|
|
17923
18324
|
"Sum of the squares of differences.",
|
|
17924
18325
|
2,
|
|
@@ -17928,7 +18329,7 @@ var SUM_FUNCTIONS = [
|
|
|
17928
18329
|
),
|
|
17929
18330
|
spec(
|
|
17930
18331
|
"SUMIF",
|
|
17931
|
-
|
|
18332
|
+
C18,
|
|
17932
18333
|
"SUMIF(range, criteria, [sum_range])",
|
|
17933
18334
|
"Adds the cells that meet a criterion.",
|
|
17934
18335
|
2,
|
|
@@ -17941,7 +18342,7 @@ var SUM_FUNCTIONS = [
|
|
|
17941
18342
|
),
|
|
17942
18343
|
spec(
|
|
17943
18344
|
"SUMIFS",
|
|
17944
|
-
|
|
18345
|
+
C18,
|
|
17945
18346
|
"SUMIFS(sum_range, criteria_range1, criteria1, ...)",
|
|
17946
18347
|
"Adds the cells that meet several criteria.",
|
|
17947
18348
|
3,
|
|
@@ -17955,7 +18356,7 @@ var SUM_FUNCTIONS = [
|
|
|
17955
18356
|
),
|
|
17956
18357
|
spec(
|
|
17957
18358
|
"SUBTOTAL",
|
|
17958
|
-
|
|
18359
|
+
C18,
|
|
17959
18360
|
"SUBTOTAL(function_num, ref1, ...)",
|
|
17960
18361
|
"A subtotal (1-11 include hidden rows, 101-111 ignore them).",
|
|
17961
18362
|
2,
|
|
@@ -17970,7 +18371,7 @@ var SUM_FUNCTIONS = [
|
|
|
17970
18371
|
),
|
|
17971
18372
|
spec(
|
|
17972
18373
|
"AGGREGATE",
|
|
17973
|
-
|
|
18374
|
+
C18,
|
|
17974
18375
|
"AGGREGATE(function_num, options, ref1, ...)",
|
|
17975
18376
|
"An aggregate that can ignore hidden rows and errors.",
|
|
17976
18377
|
3,
|
|
@@ -18010,14 +18411,14 @@ var SUM_FUNCTIONS = [
|
|
|
18010
18411
|
];
|
|
18011
18412
|
|
|
18012
18413
|
// src/xlsx/formula/functions/math-more.ts
|
|
18013
|
-
var
|
|
18414
|
+
var C19 = "Math & Trig";
|
|
18014
18415
|
var MATH_MORE = [
|
|
18015
|
-
numeric("SIN",
|
|
18016
|
-
numeric("COS",
|
|
18017
|
-
numeric("TAN",
|
|
18416
|
+
numeric("SIN", C19, "SIN(number)", "The sine of an angle in radians.", 1, 1, Math.sin),
|
|
18417
|
+
numeric("COS", C19, "COS(number)", "The cosine of an angle in radians.", 1, 1, Math.cos),
|
|
18418
|
+
numeric("TAN", C19, "TAN(number)", "The tangent of an angle in radians.", 1, 1, Math.tan),
|
|
18018
18419
|
numeric(
|
|
18019
18420
|
"ASIN",
|
|
18020
|
-
|
|
18421
|
+
C19,
|
|
18021
18422
|
"ASIN(number)",
|
|
18022
18423
|
"The arcsine in radians.",
|
|
18023
18424
|
1,
|
|
@@ -18026,17 +18427,17 @@ var MATH_MORE = [
|
|
|
18026
18427
|
),
|
|
18027
18428
|
numeric(
|
|
18028
18429
|
"ACOS",
|
|
18029
|
-
|
|
18430
|
+
C19,
|
|
18030
18431
|
"ACOS(number)",
|
|
18031
18432
|
"The arccosine in radians.",
|
|
18032
18433
|
1,
|
|
18033
18434
|
1,
|
|
18034
18435
|
(x) => domain(Math.abs(x) <= 1, Math.acos(x))
|
|
18035
18436
|
),
|
|
18036
|
-
numeric("ATAN",
|
|
18437
|
+
numeric("ATAN", C19, "ATAN(number)", "The arctangent in radians.", 1, 1, Math.atan),
|
|
18037
18438
|
numeric(
|
|
18038
18439
|
"ATAN2",
|
|
18039
|
-
|
|
18440
|
+
C19,
|
|
18040
18441
|
"ATAN2(x_num, y_num)",
|
|
18041
18442
|
"The arctangent of x and y coordinates.",
|
|
18042
18443
|
2,
|
|
@@ -18046,13 +18447,13 @@ var MATH_MORE = [
|
|
|
18046
18447
|
return Math.atan2(y ?? 0, x);
|
|
18047
18448
|
}
|
|
18048
18449
|
),
|
|
18049
|
-
numeric("SINH",
|
|
18050
|
-
numeric("COSH",
|
|
18051
|
-
numeric("TANH",
|
|
18052
|
-
numeric("ASINH",
|
|
18450
|
+
numeric("SINH", C19, "SINH(number)", "The hyperbolic sine.", 1, 1, Math.sinh),
|
|
18451
|
+
numeric("COSH", C19, "COSH(number)", "The hyperbolic cosine.", 1, 1, Math.cosh),
|
|
18452
|
+
numeric("TANH", C19, "TANH(number)", "The hyperbolic tangent.", 1, 1, Math.tanh),
|
|
18453
|
+
numeric("ASINH", C19, "ASINH(number)", "The inverse hyperbolic sine.", 1, 1, Math.asinh),
|
|
18053
18454
|
numeric(
|
|
18054
18455
|
"ACOSH",
|
|
18055
|
-
|
|
18456
|
+
C19,
|
|
18056
18457
|
"ACOSH(number)",
|
|
18057
18458
|
"The inverse hyperbolic cosine.",
|
|
18058
18459
|
1,
|
|
@@ -18061,7 +18462,7 @@ var MATH_MORE = [
|
|
|
18061
18462
|
),
|
|
18062
18463
|
numeric(
|
|
18063
18464
|
"ATANH",
|
|
18064
|
-
|
|
18465
|
+
C19,
|
|
18065
18466
|
"ATANH(number)",
|
|
18066
18467
|
"The inverse hyperbolic tangent.",
|
|
18067
18468
|
1,
|
|
@@ -18070,7 +18471,7 @@ var MATH_MORE = [
|
|
|
18070
18471
|
),
|
|
18071
18472
|
numeric(
|
|
18072
18473
|
"COT",
|
|
18073
|
-
|
|
18474
|
+
C19,
|
|
18074
18475
|
"COT(number)",
|
|
18075
18476
|
"The cotangent of an angle.",
|
|
18076
18477
|
1,
|
|
@@ -18079,7 +18480,7 @@ var MATH_MORE = [
|
|
|
18079
18480
|
),
|
|
18080
18481
|
numeric(
|
|
18081
18482
|
"COTH",
|
|
18082
|
-
|
|
18483
|
+
C19,
|
|
18083
18484
|
"COTH(number)",
|
|
18084
18485
|
"The hyperbolic cotangent.",
|
|
18085
18486
|
1,
|
|
@@ -18088,7 +18489,7 @@ var MATH_MORE = [
|
|
|
18088
18489
|
),
|
|
18089
18490
|
numeric(
|
|
18090
18491
|
"CSC",
|
|
18091
|
-
|
|
18492
|
+
C19,
|
|
18092
18493
|
"CSC(number)",
|
|
18093
18494
|
"The cosecant of an angle.",
|
|
18094
18495
|
1,
|
|
@@ -18097,19 +18498,19 @@ var MATH_MORE = [
|
|
|
18097
18498
|
),
|
|
18098
18499
|
numeric(
|
|
18099
18500
|
"CSCH",
|
|
18100
|
-
|
|
18501
|
+
C19,
|
|
18101
18502
|
"CSCH(number)",
|
|
18102
18503
|
"The hyperbolic cosecant.",
|
|
18103
18504
|
1,
|
|
18104
18505
|
1,
|
|
18105
18506
|
(x) => x === 0 ? fail(ERR.DIV0) : 1 / Math.sinh(x)
|
|
18106
18507
|
),
|
|
18107
|
-
numeric("SEC",
|
|
18108
|
-
numeric("SECH",
|
|
18109
|
-
numeric("ACOT",
|
|
18508
|
+
numeric("SEC", C19, "SEC(number)", "The secant of an angle.", 1, 1, (x) => 1 / Math.cos(x)),
|
|
18509
|
+
numeric("SECH", C19, "SECH(number)", "The hyperbolic secant.", 1, 1, (x) => 1 / Math.cosh(x)),
|
|
18510
|
+
numeric("ACOT", C19, "ACOT(number)", "The arccotangent.", 1, 1, (x) => Math.PI / 2 - Math.atan(x)),
|
|
18110
18511
|
numeric(
|
|
18111
18512
|
"ACOTH",
|
|
18112
|
-
|
|
18513
|
+
C19,
|
|
18113
18514
|
"ACOTH(number)",
|
|
18114
18515
|
"The inverse hyperbolic cotangent.",
|
|
18115
18516
|
1,
|
|
@@ -18118,7 +18519,7 @@ var MATH_MORE = [
|
|
|
18118
18519
|
),
|
|
18119
18520
|
numeric(
|
|
18120
18521
|
"DEGREES",
|
|
18121
|
-
|
|
18522
|
+
C19,
|
|
18122
18523
|
"DEGREES(angle)",
|
|
18123
18524
|
"Converts radians to degrees.",
|
|
18124
18525
|
1,
|
|
@@ -18127,7 +18528,7 @@ var MATH_MORE = [
|
|
|
18127
18528
|
),
|
|
18128
18529
|
numeric(
|
|
18129
18530
|
"RADIANS",
|
|
18130
|
-
|
|
18531
|
+
C19,
|
|
18131
18532
|
"RADIANS(angle)",
|
|
18132
18533
|
"Converts degrees to radians.",
|
|
18133
18534
|
1,
|
|
@@ -18136,7 +18537,7 @@ var MATH_MORE = [
|
|
|
18136
18537
|
),
|
|
18137
18538
|
spec(
|
|
18138
18539
|
"RAND",
|
|
18139
|
-
|
|
18540
|
+
C19,
|
|
18140
18541
|
"RAND()",
|
|
18141
18542
|
"A random number between 0 and 1.",
|
|
18142
18543
|
0,
|
|
@@ -18147,7 +18548,7 @@ var MATH_MORE = [
|
|
|
18147
18548
|
),
|
|
18148
18549
|
spec(
|
|
18149
18550
|
"RANDBETWEEN",
|
|
18150
|
-
|
|
18551
|
+
C19,
|
|
18151
18552
|
"RANDBETWEEN(bottom, top)",
|
|
18152
18553
|
"A random integer between two numbers.",
|
|
18153
18554
|
2,
|
|
@@ -18163,7 +18564,7 @@ var MATH_MORE = [
|
|
|
18163
18564
|
),
|
|
18164
18565
|
spec(
|
|
18165
18566
|
"SERIESSUM",
|
|
18166
|
-
|
|
18567
|
+
C19,
|
|
18167
18568
|
"SERIESSUM(x, n, m, coefficients)",
|
|
18168
18569
|
"The sum of a power series.",
|
|
18169
18570
|
4,
|
|
@@ -18182,7 +18583,7 @@ var MATH_MORE = [
|
|
|
18182
18583
|
];
|
|
18183
18584
|
|
|
18184
18585
|
// src/xlsx/formula/functions/math-combin.ts
|
|
18185
|
-
var
|
|
18586
|
+
var C20 = "Math & Trig";
|
|
18186
18587
|
var fact = (n) => {
|
|
18187
18588
|
if (n < 0) fail(ERR.NUM);
|
|
18188
18589
|
let out = 1;
|
|
@@ -18206,8 +18607,8 @@ function integers(args, ctx) {
|
|
|
18206
18607
|
});
|
|
18207
18608
|
}
|
|
18208
18609
|
var COMBINATORIC_FUNCTIONS = [
|
|
18209
|
-
numeric("FACT",
|
|
18210
|
-
numeric("FACTDOUBLE",
|
|
18610
|
+
numeric("FACT", C20, "FACT(number)", "The factorial of a number.", 1, 1, fact),
|
|
18611
|
+
numeric("FACTDOUBLE", C20, "FACTDOUBLE(number)", "The double factorial of a number.", 1, 1, (n) => {
|
|
18211
18612
|
if (n < -1) fail(ERR.NUM);
|
|
18212
18613
|
let out = 1;
|
|
18213
18614
|
for (let i = Math.trunc(n); i > 1; i -= 2) out *= i;
|
|
@@ -18215,7 +18616,7 @@ var COMBINATORIC_FUNCTIONS = [
|
|
|
18215
18616
|
}),
|
|
18216
18617
|
numeric(
|
|
18217
18618
|
"COMBIN",
|
|
18218
|
-
|
|
18619
|
+
C20,
|
|
18219
18620
|
"COMBIN(number, number_chosen)",
|
|
18220
18621
|
"The number of combinations.",
|
|
18221
18622
|
2,
|
|
@@ -18224,7 +18625,7 @@ var COMBINATORIC_FUNCTIONS = [
|
|
|
18224
18625
|
),
|
|
18225
18626
|
numeric(
|
|
18226
18627
|
"COMBINA",
|
|
18227
|
-
|
|
18628
|
+
C20,
|
|
18228
18629
|
"COMBINA(number, number_chosen)",
|
|
18229
18630
|
"Combinations with repetitions.",
|
|
18230
18631
|
2,
|
|
@@ -18236,7 +18637,7 @@ var COMBINATORIC_FUNCTIONS = [
|
|
|
18236
18637
|
),
|
|
18237
18638
|
spec(
|
|
18238
18639
|
"MULTINOMIAL",
|
|
18239
|
-
|
|
18640
|
+
C20,
|
|
18240
18641
|
"MULTINOMIAL(number1, ...)",
|
|
18241
18642
|
"The multinomial of a set of numbers.",
|
|
18242
18643
|
1,
|
|
@@ -18250,7 +18651,7 @@ var COMBINATORIC_FUNCTIONS = [
|
|
|
18250
18651
|
),
|
|
18251
18652
|
spec(
|
|
18252
18653
|
"GCD",
|
|
18253
|
-
|
|
18654
|
+
C20,
|
|
18254
18655
|
"GCD(number1, ...)",
|
|
18255
18656
|
"The greatest common divisor.",
|
|
18256
18657
|
1,
|
|
@@ -18260,7 +18661,7 @@ var COMBINATORIC_FUNCTIONS = [
|
|
|
18260
18661
|
),
|
|
18261
18662
|
spec(
|
|
18262
18663
|
"LCM",
|
|
18263
|
-
|
|
18664
|
+
C20,
|
|
18264
18665
|
"LCM(number1, ...)",
|
|
18265
18666
|
"The least common multiple.",
|
|
18266
18667
|
1,
|
|
@@ -18308,7 +18709,7 @@ function mround(x, m) {
|
|
|
18308
18709
|
}
|
|
18309
18710
|
|
|
18310
18711
|
// src/xlsx/formula/functions/math.ts
|
|
18311
|
-
var
|
|
18712
|
+
var C21 = "Math & Trig";
|
|
18312
18713
|
function roundTo(x, digits2, mode) {
|
|
18313
18714
|
if (!Number.isFinite(x)) return x;
|
|
18314
18715
|
const d = Math.trunc(digits2);
|
|
@@ -18327,10 +18728,10 @@ var quotientMultiple = (x, sig, op) => {
|
|
|
18327
18728
|
var MATH_FUNCTIONS = [
|
|
18328
18729
|
...MATH_MORE,
|
|
18329
18730
|
...SUM_FUNCTIONS,
|
|
18330
|
-
numeric("ABS",
|
|
18731
|
+
numeric("ABS", C21, "ABS(number)", "The absolute value of a number.", 1, 1, Math.abs),
|
|
18331
18732
|
numeric(
|
|
18332
18733
|
"SIGN",
|
|
18333
|
-
|
|
18734
|
+
C21,
|
|
18334
18735
|
"SIGN(number)",
|
|
18335
18736
|
"The sign of a number: 1, 0 or -1.",
|
|
18336
18737
|
1,
|
|
@@ -18339,7 +18740,7 @@ var MATH_FUNCTIONS = [
|
|
|
18339
18740
|
),
|
|
18340
18741
|
numeric(
|
|
18341
18742
|
"INT",
|
|
18342
|
-
|
|
18743
|
+
C21,
|
|
18343
18744
|
"INT(number)",
|
|
18344
18745
|
"Rounds a number down to the nearest integer.",
|
|
18345
18746
|
1,
|
|
@@ -18348,7 +18749,7 @@ var MATH_FUNCTIONS = [
|
|
|
18348
18749
|
),
|
|
18349
18750
|
numeric(
|
|
18350
18751
|
"TRUNC",
|
|
18351
|
-
|
|
18752
|
+
C21,
|
|
18352
18753
|
"TRUNC(number, [num_digits])",
|
|
18353
18754
|
"Truncates a number toward zero.",
|
|
18354
18755
|
1,
|
|
@@ -18357,7 +18758,7 @@ var MATH_FUNCTIONS = [
|
|
|
18357
18758
|
),
|
|
18358
18759
|
numeric(
|
|
18359
18760
|
"ROUND",
|
|
18360
|
-
|
|
18761
|
+
C21,
|
|
18361
18762
|
"ROUND(number, num_digits)",
|
|
18362
18763
|
"Rounds a number to a number of digits.",
|
|
18363
18764
|
2,
|
|
@@ -18366,7 +18767,7 @@ var MATH_FUNCTIONS = [
|
|
|
18366
18767
|
),
|
|
18367
18768
|
numeric(
|
|
18368
18769
|
"ROUNDUP",
|
|
18369
|
-
|
|
18770
|
+
C21,
|
|
18370
18771
|
"ROUNDUP(number, num_digits)",
|
|
18371
18772
|
"Rounds a number away from zero.",
|
|
18372
18773
|
2,
|
|
@@ -18375,7 +18776,7 @@ var MATH_FUNCTIONS = [
|
|
|
18375
18776
|
),
|
|
18376
18777
|
numeric(
|
|
18377
18778
|
"ROUNDDOWN",
|
|
18378
|
-
|
|
18779
|
+
C21,
|
|
18379
18780
|
"ROUNDDOWN(number, num_digits)",
|
|
18380
18781
|
"Rounds a number toward zero.",
|
|
18381
18782
|
2,
|
|
@@ -18384,7 +18785,7 @@ var MATH_FUNCTIONS = [
|
|
|
18384
18785
|
),
|
|
18385
18786
|
numeric(
|
|
18386
18787
|
"MROUND",
|
|
18387
|
-
|
|
18788
|
+
C21,
|
|
18388
18789
|
"MROUND(number, multiple)",
|
|
18389
18790
|
"Rounds a number to the nearest multiple.",
|
|
18390
18791
|
2,
|
|
@@ -18393,7 +18794,7 @@ var MATH_FUNCTIONS = [
|
|
|
18393
18794
|
),
|
|
18394
18795
|
numeric(
|
|
18395
18796
|
"CEILING",
|
|
18396
|
-
|
|
18797
|
+
C21,
|
|
18397
18798
|
"CEILING(number, significance)",
|
|
18398
18799
|
"Rounds a number up to a multiple of significance.",
|
|
18399
18800
|
2,
|
|
@@ -18405,7 +18806,7 @@ var MATH_FUNCTIONS = [
|
|
|
18405
18806
|
),
|
|
18406
18807
|
numeric(
|
|
18407
18808
|
"FLOOR",
|
|
18408
|
-
|
|
18809
|
+
C21,
|
|
18409
18810
|
"FLOOR(number, significance)",
|
|
18410
18811
|
"Rounds a number down to a multiple of significance.",
|
|
18411
18812
|
2,
|
|
@@ -18418,7 +18819,7 @@ var MATH_FUNCTIONS = [
|
|
|
18418
18819
|
),
|
|
18419
18820
|
numeric(
|
|
18420
18821
|
"CEILING.MATH",
|
|
18421
|
-
|
|
18822
|
+
C21,
|
|
18422
18823
|
"CEILING.MATH(number, [significance], [mode])",
|
|
18423
18824
|
"Rounds a number up to an integer or multiple.",
|
|
18424
18825
|
1,
|
|
@@ -18431,7 +18832,7 @@ var MATH_FUNCTIONS = [
|
|
|
18431
18832
|
),
|
|
18432
18833
|
numeric(
|
|
18433
18834
|
"FLOOR.MATH",
|
|
18434
|
-
|
|
18835
|
+
C21,
|
|
18435
18836
|
"FLOOR.MATH(number, [significance], [mode])",
|
|
18436
18837
|
"Rounds a number down to an integer or multiple.",
|
|
18437
18838
|
1,
|
|
@@ -18444,7 +18845,7 @@ var MATH_FUNCTIONS = [
|
|
|
18444
18845
|
),
|
|
18445
18846
|
numeric(
|
|
18446
18847
|
"CEILING.PRECISE",
|
|
18447
|
-
|
|
18848
|
+
C21,
|
|
18448
18849
|
"CEILING.PRECISE(number, [significance])",
|
|
18449
18850
|
"Rounds a number up regardless of sign.",
|
|
18450
18851
|
1,
|
|
@@ -18453,7 +18854,7 @@ var MATH_FUNCTIONS = [
|
|
|
18453
18854
|
),
|
|
18454
18855
|
numeric(
|
|
18455
18856
|
"ISO.CEILING",
|
|
18456
|
-
|
|
18857
|
+
C21,
|
|
18457
18858
|
"ISO.CEILING(number, [significance])",
|
|
18458
18859
|
"Rounds a number up regardless of sign.",
|
|
18459
18860
|
1,
|
|
@@ -18462,7 +18863,7 @@ var MATH_FUNCTIONS = [
|
|
|
18462
18863
|
),
|
|
18463
18864
|
numeric(
|
|
18464
18865
|
"FLOOR.PRECISE",
|
|
18465
|
-
|
|
18866
|
+
C21,
|
|
18466
18867
|
"FLOOR.PRECISE(number, [significance])",
|
|
18467
18868
|
"Rounds a number down regardless of sign.",
|
|
18468
18869
|
1,
|
|
@@ -18471,7 +18872,7 @@ var MATH_FUNCTIONS = [
|
|
|
18471
18872
|
),
|
|
18472
18873
|
numeric(
|
|
18473
18874
|
"EVEN",
|
|
18474
|
-
|
|
18875
|
+
C21,
|
|
18475
18876
|
"EVEN(number)",
|
|
18476
18877
|
"Rounds a number away from zero to an even integer.",
|
|
18477
18878
|
1,
|
|
@@ -18480,7 +18881,7 @@ var MATH_FUNCTIONS = [
|
|
|
18480
18881
|
),
|
|
18481
18882
|
numeric(
|
|
18482
18883
|
"ODD",
|
|
18483
|
-
|
|
18884
|
+
C21,
|
|
18484
18885
|
"ODD(number)",
|
|
18485
18886
|
"Rounds a number away from zero to an odd integer.",
|
|
18486
18887
|
1,
|
|
@@ -18492,7 +18893,7 @@ var MATH_FUNCTIONS = [
|
|
|
18492
18893
|
),
|
|
18493
18894
|
numeric(
|
|
18494
18895
|
"MOD",
|
|
18495
|
-
|
|
18896
|
+
C21,
|
|
18496
18897
|
"MOD(number, divisor)",
|
|
18497
18898
|
"The remainder after division (sign of the divisor).",
|
|
18498
18899
|
2,
|
|
@@ -18501,7 +18902,7 @@ var MATH_FUNCTIONS = [
|
|
|
18501
18902
|
),
|
|
18502
18903
|
numeric(
|
|
18503
18904
|
"QUOTIENT",
|
|
18504
|
-
|
|
18905
|
+
C21,
|
|
18505
18906
|
"QUOTIENT(numerator, denominator)",
|
|
18506
18907
|
"The integer part of a division.",
|
|
18507
18908
|
2,
|
|
@@ -18513,7 +18914,7 @@ var MATH_FUNCTIONS = [
|
|
|
18513
18914
|
),
|
|
18514
18915
|
numeric(
|
|
18515
18916
|
"SQRT",
|
|
18516
|
-
|
|
18917
|
+
C21,
|
|
18517
18918
|
"SQRT(number)",
|
|
18518
18919
|
"The positive square root.",
|
|
18519
18920
|
1,
|
|
@@ -18522,7 +18923,7 @@ var MATH_FUNCTIONS = [
|
|
|
18522
18923
|
),
|
|
18523
18924
|
numeric(
|
|
18524
18925
|
"SQRTPI",
|
|
18525
|
-
|
|
18926
|
+
C21,
|
|
18526
18927
|
"SQRTPI(number)",
|
|
18527
18928
|
"The square root of number * pi.",
|
|
18528
18929
|
1,
|
|
@@ -18531,18 +18932,18 @@ var MATH_FUNCTIONS = [
|
|
|
18531
18932
|
),
|
|
18532
18933
|
numeric(
|
|
18533
18934
|
"POWER",
|
|
18534
|
-
|
|
18935
|
+
C21,
|
|
18535
18936
|
"POWER(number, power)",
|
|
18536
18937
|
"A number raised to a power.",
|
|
18537
18938
|
2,
|
|
18538
18939
|
2,
|
|
18539
18940
|
(b, e) => power(b, e ?? 1)
|
|
18540
18941
|
),
|
|
18541
|
-
numeric("EXP",
|
|
18542
|
-
numeric("LN",
|
|
18942
|
+
numeric("EXP", C21, "EXP(number)", "e raised to a power.", 1, 1, Math.exp),
|
|
18943
|
+
numeric("LN", C21, "LN(number)", "The natural logarithm.", 1, 1, (x) => domain(x > 0, Math.log(x))),
|
|
18543
18944
|
numeric(
|
|
18544
18945
|
"LOG10",
|
|
18545
|
-
|
|
18946
|
+
C21,
|
|
18546
18947
|
"LOG10(number)",
|
|
18547
18948
|
"The base-10 logarithm.",
|
|
18548
18949
|
1,
|
|
@@ -18551,7 +18952,7 @@ var MATH_FUNCTIONS = [
|
|
|
18551
18952
|
),
|
|
18552
18953
|
numeric(
|
|
18553
18954
|
"LOG",
|
|
18554
|
-
|
|
18955
|
+
C21,
|
|
18555
18956
|
"LOG(number, [base])",
|
|
18556
18957
|
"The logarithm to a base (10 by default).",
|
|
18557
18958
|
1,
|
|
@@ -18563,12 +18964,12 @@ var MATH_FUNCTIONS = [
|
|
|
18563
18964
|
return base === 10 ? Math.log10(x) : Math.log(x) / Math.log(base);
|
|
18564
18965
|
}
|
|
18565
18966
|
),
|
|
18566
|
-
numeric("PI",
|
|
18967
|
+
numeric("PI", C21, "PI()", "The value of pi.", 0, 0, () => Math.PI),
|
|
18567
18968
|
...COMBINATORIC_FUNCTIONS
|
|
18568
18969
|
];
|
|
18569
18970
|
|
|
18570
18971
|
// src/xlsx/formula/functions/matrix.ts
|
|
18571
|
-
var
|
|
18972
|
+
var C22 = "Math & Trig";
|
|
18572
18973
|
function numbers2(ctx, value) {
|
|
18573
18974
|
return ctx.toMatrix(value ?? null).data.map(
|
|
18574
18975
|
(row2) => row2.map((v) => {
|
|
@@ -18627,7 +19028,7 @@ function eliminate(input, invert2) {
|
|
|
18627
19028
|
var MATRIX_FUNCTIONS = [
|
|
18628
19029
|
spec(
|
|
18629
19030
|
"MMULT",
|
|
18630
|
-
|
|
19031
|
+
C22,
|
|
18631
19032
|
"MMULT(array1, array2)",
|
|
18632
19033
|
"The matrix product of two arrays.",
|
|
18633
19034
|
2,
|
|
@@ -18648,7 +19049,7 @@ var MATRIX_FUNCTIONS = [
|
|
|
18648
19049
|
),
|
|
18649
19050
|
spec(
|
|
18650
19051
|
"MDETERM",
|
|
18651
|
-
|
|
19052
|
+
C22,
|
|
18652
19053
|
"MDETERM(array)",
|
|
18653
19054
|
"The determinant of a square matrix.",
|
|
18654
19055
|
1,
|
|
@@ -18658,7 +19059,7 @@ var MATRIX_FUNCTIONS = [
|
|
|
18658
19059
|
),
|
|
18659
19060
|
spec(
|
|
18660
19061
|
"MINVERSE",
|
|
18661
|
-
|
|
19062
|
+
C22,
|
|
18662
19063
|
"MINVERSE(array)",
|
|
18663
19064
|
"The inverse of a square matrix.",
|
|
18664
19065
|
1,
|
|
@@ -18670,7 +19071,7 @@ var MATRIX_FUNCTIONS = [
|
|
|
18670
19071
|
},
|
|
18671
19072
|
["any"]
|
|
18672
19073
|
),
|
|
18673
|
-
spec("MUNIT",
|
|
19074
|
+
spec("MUNIT", C22, "MUNIT(dimension)", "The identity matrix.", 1, 1, (args) => {
|
|
18674
19075
|
const n = int3(args[0]);
|
|
18675
19076
|
if (n < 1) fail(ERR.VALUE);
|
|
18676
19077
|
return Matrix.build(n, n, (r, c2) => r === c2 ? 1 : 0);
|
|
@@ -18737,7 +19138,7 @@ function fitStatistics(fit) {
|
|
|
18737
19138
|
}
|
|
18738
19139
|
|
|
18739
19140
|
// src/xlsx/formula/functions/regression.ts
|
|
18740
|
-
var
|
|
19141
|
+
var C23 = "Statistical";
|
|
18741
19142
|
function numbersOf2(ctx, value) {
|
|
18742
19143
|
return ctx.toMatrix(value ?? null).data.map(
|
|
18743
19144
|
(row2) => row2.map((v) => {
|
|
@@ -18806,7 +19207,7 @@ var ARGS = ["any"];
|
|
|
18806
19207
|
var REGRESSION_FUNCTIONS = [
|
|
18807
19208
|
spec(
|
|
18808
19209
|
"LINEST",
|
|
18809
|
-
|
|
19210
|
+
C23,
|
|
18810
19211
|
"LINEST(known_y, [known_x], [const], [stats])",
|
|
18811
19212
|
"The statistics of a straight-line (or multiple linear) least-squares fit.",
|
|
18812
19213
|
1,
|
|
@@ -18820,7 +19221,7 @@ var REGRESSION_FUNCTIONS = [
|
|
|
18820
19221
|
),
|
|
18821
19222
|
spec(
|
|
18822
19223
|
"LOGEST",
|
|
18823
|
-
|
|
19224
|
+
C23,
|
|
18824
19225
|
"LOGEST(known_y, [known_x], [const], [stats])",
|
|
18825
19226
|
"The statistics of an exponential-curve fit.",
|
|
18826
19227
|
1,
|
|
@@ -18838,7 +19239,7 @@ var REGRESSION_FUNCTIONS = [
|
|
|
18838
19239
|
),
|
|
18839
19240
|
spec(
|
|
18840
19241
|
"TREND",
|
|
18841
|
-
|
|
19242
|
+
C23,
|
|
18842
19243
|
"TREND(known_y, [known_x], [new_x], [const])",
|
|
18843
19244
|
"Values along a linear trend.",
|
|
18844
19245
|
1,
|
|
@@ -18852,7 +19253,7 @@ var REGRESSION_FUNCTIONS = [
|
|
|
18852
19253
|
),
|
|
18853
19254
|
spec(
|
|
18854
19255
|
"GROWTH",
|
|
18855
|
-
|
|
19256
|
+
C23,
|
|
18856
19257
|
"GROWTH(known_y, [known_x], [new_x], [const])",
|
|
18857
19258
|
"Values along an exponential trend.",
|
|
18858
19259
|
1,
|
|
@@ -19006,7 +19407,7 @@ var tPdf = (t, df) => Math.exp(
|
|
|
19006
19407
|
gammaLn((df + 1) / 2) - gammaLn(df / 2) - 0.5 * Math.log(df * Math.PI) - (df + 1) / 2 * Math.log(1 + t * t / df)
|
|
19007
19408
|
);
|
|
19008
19409
|
var chiCdf = (x, df) => gammaP(df / 2, x / 2);
|
|
19009
|
-
var
|
|
19410
|
+
var positive2 = (...values2) => {
|
|
19010
19411
|
for (const v of values2) if (v === void 0 || v <= 0) fail(ERR.NUM);
|
|
19011
19412
|
};
|
|
19012
19413
|
var probability = (p) => {
|
|
@@ -19031,13 +19432,13 @@ function poisson(k, mean2, cumulative2) {
|
|
|
19031
19432
|
return Math.exp(kk * Math.log(mean2) - mean2 - gammaLn(kk + 1));
|
|
19032
19433
|
}
|
|
19033
19434
|
var normDist = (x, m, s, cumulative2) => {
|
|
19034
|
-
|
|
19435
|
+
positive2(s);
|
|
19035
19436
|
const z = (x - m) / s;
|
|
19036
19437
|
return cumulative2 ? normCdf(z) : normPdf(z) / s;
|
|
19037
19438
|
};
|
|
19038
19439
|
|
|
19039
19440
|
// src/xlsx/formula/functions/distributions-f.ts
|
|
19040
|
-
var
|
|
19441
|
+
var C24 = "Statistical";
|
|
19041
19442
|
var degrees = (...values2) => {
|
|
19042
19443
|
for (const v of values2) if (v === void 0 || v < 1) fail(ERR.NUM);
|
|
19043
19444
|
};
|
|
@@ -19058,13 +19459,13 @@ var betaScaled = (x, a, b, lo, hi) => {
|
|
|
19058
19459
|
return betaI((x - lo) / (hi - lo), a, b);
|
|
19059
19460
|
};
|
|
19060
19461
|
var betaInverse = (p, a, b, lo, hi) => {
|
|
19061
|
-
|
|
19462
|
+
positive2(a, b);
|
|
19062
19463
|
if (p <= 0 || p > 1 || lo >= hi) fail(ERR.NUM);
|
|
19063
19464
|
return lo + (hi - lo) * invert((t) => betaI(t, a, b), p, 0, 1);
|
|
19064
19465
|
};
|
|
19065
19466
|
var gammaInverse = (p, a, b) => {
|
|
19066
19467
|
prob(p);
|
|
19067
|
-
|
|
19468
|
+
positive2(a, b);
|
|
19068
19469
|
return p === 0 ? 0 : invert((x) => gammaP(a, x / b), p, 0, a * b + 1);
|
|
19069
19470
|
};
|
|
19070
19471
|
function binomInverse(trials, p, alpha) {
|
|
@@ -19096,7 +19497,7 @@ var negbinomPmf = (f, s, p) => {
|
|
|
19096
19497
|
var DISTRIBUTION_F = [
|
|
19097
19498
|
numeric(
|
|
19098
19499
|
"F.DIST",
|
|
19099
|
-
|
|
19500
|
+
C24,
|
|
19100
19501
|
"F.DIST(x, deg_freedom1, deg_freedom2, cumulative)",
|
|
19101
19502
|
"The left-tailed F probability distribution.",
|
|
19102
19503
|
4,
|
|
@@ -19112,7 +19513,7 @@ var DISTRIBUTION_F = [
|
|
|
19112
19513
|
...["F.DIST.RT", "FDIST"].map(
|
|
19113
19514
|
(name) => numeric(
|
|
19114
19515
|
name,
|
|
19115
|
-
|
|
19516
|
+
C24,
|
|
19116
19517
|
`${name}(x, deg_freedom1, deg_freedom2)`,
|
|
19117
19518
|
"The right-tailed F probability distribution.",
|
|
19118
19519
|
3,
|
|
@@ -19126,7 +19527,7 @@ var DISTRIBUTION_F = [
|
|
|
19126
19527
|
),
|
|
19127
19528
|
numeric(
|
|
19128
19529
|
"F.INV",
|
|
19129
|
-
|
|
19530
|
+
C24,
|
|
19130
19531
|
"F.INV(probability, deg_freedom1, deg_freedom2)",
|
|
19131
19532
|
"The inverse of the left-tailed F distribution.",
|
|
19132
19533
|
3,
|
|
@@ -19140,7 +19541,7 @@ var DISTRIBUTION_F = [
|
|
|
19140
19541
|
...["F.INV.RT", "FINV"].map(
|
|
19141
19542
|
(name) => numeric(
|
|
19142
19543
|
name,
|
|
19143
|
-
|
|
19544
|
+
C24,
|
|
19144
19545
|
`${name}(probability, deg_freedom1, deg_freedom2)`,
|
|
19145
19546
|
"The inverse of the right-tailed F distribution.",
|
|
19146
19547
|
3,
|
|
@@ -19155,7 +19556,7 @@ var DISTRIBUTION_F = [
|
|
|
19155
19556
|
...["BETA.INV", "BETAINV"].map(
|
|
19156
19557
|
(name) => numeric(
|
|
19157
19558
|
name,
|
|
19158
|
-
|
|
19559
|
+
C24,
|
|
19159
19560
|
`${name}(probability, alpha, beta, [A], [B])`,
|
|
19160
19561
|
"The inverse of the cumulative beta distribution.",
|
|
19161
19562
|
3,
|
|
@@ -19166,13 +19567,13 @@ var DISTRIBUTION_F = [
|
|
|
19166
19567
|
),
|
|
19167
19568
|
numeric(
|
|
19168
19569
|
"BETADIST",
|
|
19169
|
-
|
|
19570
|
+
C24,
|
|
19170
19571
|
"BETADIST(x, alpha, beta, [A], [B])",
|
|
19171
19572
|
"The cumulative beta distribution.",
|
|
19172
19573
|
3,
|
|
19173
19574
|
5,
|
|
19174
19575
|
(x, a, b, lo, hi) => {
|
|
19175
|
-
|
|
19576
|
+
positive2(a, b);
|
|
19176
19577
|
return betaScaled(x, a ?? 1, b ?? 1, lo ?? 0, hi ?? 1);
|
|
19177
19578
|
},
|
|
19178
19579
|
[0, 0, 0, 0, 1]
|
|
@@ -19180,7 +19581,7 @@ var DISTRIBUTION_F = [
|
|
|
19180
19581
|
...["GAMMA.INV", "GAMMAINV"].map(
|
|
19181
19582
|
(name) => numeric(
|
|
19182
19583
|
name,
|
|
19183
|
-
|
|
19584
|
+
C24,
|
|
19184
19585
|
`${name}(probability, alpha, beta)`,
|
|
19185
19586
|
"The inverse of the gamma cumulative distribution.",
|
|
19186
19587
|
3,
|
|
@@ -19190,14 +19591,14 @@ var DISTRIBUTION_F = [
|
|
|
19190
19591
|
),
|
|
19191
19592
|
numeric(
|
|
19192
19593
|
"GAMMADIST",
|
|
19193
|
-
|
|
19594
|
+
C24,
|
|
19194
19595
|
"GAMMADIST(x, alpha, beta, cumulative)",
|
|
19195
19596
|
"The gamma distribution.",
|
|
19196
19597
|
4,
|
|
19197
19598
|
4,
|
|
19198
19599
|
(x, a, b, c2) => {
|
|
19199
19600
|
if (x < 0) fail(ERR.NUM);
|
|
19200
|
-
|
|
19601
|
+
positive2(a, b);
|
|
19201
19602
|
const al = a ?? 1;
|
|
19202
19603
|
const be = b ?? 1;
|
|
19203
19604
|
return c2 ? gammaP(al, x / be) : Math.exp((al - 1) * Math.log(x) - x / be - gammaLn(al) - al * Math.log(be));
|
|
@@ -19205,33 +19606,33 @@ var DISTRIBUTION_F = [
|
|
|
19205
19606
|
),
|
|
19206
19607
|
numeric(
|
|
19207
19608
|
"LOGINV",
|
|
19208
|
-
|
|
19609
|
+
C24,
|
|
19209
19610
|
"LOGINV(probability, mean, standard_dev)",
|
|
19210
19611
|
"The inverse of the lognormal cumulative distribution.",
|
|
19211
19612
|
3,
|
|
19212
19613
|
3,
|
|
19213
19614
|
(p, m, s) => {
|
|
19214
|
-
|
|
19615
|
+
positive2(s);
|
|
19215
19616
|
if (p <= 0 || p >= 1) fail(ERR.NUM);
|
|
19216
19617
|
return Math.exp((m ?? 0) + (s ?? 1) * normInv(p));
|
|
19217
19618
|
}
|
|
19218
19619
|
),
|
|
19219
19620
|
numeric(
|
|
19220
19621
|
"LOGNORMDIST",
|
|
19221
|
-
|
|
19622
|
+
C24,
|
|
19222
19623
|
"LOGNORMDIST(x, mean, standard_dev)",
|
|
19223
19624
|
"The cumulative lognormal distribution.",
|
|
19224
19625
|
3,
|
|
19225
19626
|
3,
|
|
19226
19627
|
(x, m, s) => {
|
|
19227
|
-
|
|
19628
|
+
positive2(x, s);
|
|
19228
19629
|
return normCdf((Math.log(x) - (m ?? 0)) / (s ?? 1));
|
|
19229
19630
|
}
|
|
19230
19631
|
),
|
|
19231
19632
|
...["BINOM.INV", "CRITBINOM"].map(
|
|
19232
19633
|
(name) => numeric(
|
|
19233
19634
|
name,
|
|
19234
|
-
|
|
19635
|
+
C24,
|
|
19235
19636
|
`${name}(trials, probability_s, alpha)`,
|
|
19236
19637
|
"The smallest value whose cumulative binomial distribution reaches the criterion.",
|
|
19237
19638
|
3,
|
|
@@ -19241,7 +19642,7 @@ var DISTRIBUTION_F = [
|
|
|
19241
19642
|
),
|
|
19242
19643
|
numeric(
|
|
19243
19644
|
"BINOM.DIST.RANGE",
|
|
19244
|
-
|
|
19645
|
+
C24,
|
|
19245
19646
|
"BINOM.DIST.RANGE(trials, probability_s, number_s, [number_s2])",
|
|
19246
19647
|
"The probability of a trial result within a range, from the binomial distribution.",
|
|
19247
19648
|
3,
|
|
@@ -19259,7 +19660,7 @@ var DISTRIBUTION_F = [
|
|
|
19259
19660
|
),
|
|
19260
19661
|
numeric(
|
|
19261
19662
|
"HYPGEOMDIST",
|
|
19262
|
-
|
|
19663
|
+
C24,
|
|
19263
19664
|
"HYPGEOMDIST(sample_s, number_sample, population_s, number_pop)",
|
|
19264
19665
|
"The hypergeometric distribution.",
|
|
19265
19666
|
4,
|
|
@@ -19268,7 +19669,7 @@ var DISTRIBUTION_F = [
|
|
|
19268
19669
|
),
|
|
19269
19670
|
numeric(
|
|
19270
19671
|
"NEGBINOMDIST",
|
|
19271
|
-
|
|
19672
|
+
C24,
|
|
19272
19673
|
"NEGBINOMDIST(number_f, number_s, probability_s)",
|
|
19273
19674
|
"The negative binomial distribution.",
|
|
19274
19675
|
3,
|
|
@@ -19278,7 +19679,7 @@ var DISTRIBUTION_F = [
|
|
|
19278
19679
|
];
|
|
19279
19680
|
|
|
19280
19681
|
// src/xlsx/formula/functions/statistical-shape.ts
|
|
19281
|
-
var
|
|
19682
|
+
var C25 = "Statistical";
|
|
19282
19683
|
function moments(values2) {
|
|
19283
19684
|
const n = values2.length;
|
|
19284
19685
|
return { n, m: mean(values2), s: stdev(values2, true) };
|
|
@@ -19295,7 +19696,7 @@ function frequency(data, bins) {
|
|
|
19295
19696
|
var STATISTICAL_SHAPE = [
|
|
19296
19697
|
spec(
|
|
19297
19698
|
"GEOMEAN",
|
|
19298
|
-
|
|
19699
|
+
C25,
|
|
19299
19700
|
"GEOMEAN(number1, ...)",
|
|
19300
19701
|
"The geometric mean.",
|
|
19301
19702
|
1,
|
|
@@ -19309,7 +19710,7 @@ var STATISTICAL_SHAPE = [
|
|
|
19309
19710
|
),
|
|
19310
19711
|
spec(
|
|
19311
19712
|
"HARMEAN",
|
|
19312
|
-
|
|
19713
|
+
C25,
|
|
19313
19714
|
"HARMEAN(number1, ...)",
|
|
19314
19715
|
"The harmonic mean.",
|
|
19315
19716
|
1,
|
|
@@ -19323,7 +19724,7 @@ var STATISTICAL_SHAPE = [
|
|
|
19323
19724
|
),
|
|
19324
19725
|
spec(
|
|
19325
19726
|
"AVEDEV",
|
|
19326
|
-
|
|
19727
|
+
C25,
|
|
19327
19728
|
"AVEDEV(number1, ...)",
|
|
19328
19729
|
"The mean absolute deviation from the mean.",
|
|
19329
19730
|
1,
|
|
@@ -19338,7 +19739,7 @@ var STATISTICAL_SHAPE = [
|
|
|
19338
19739
|
),
|
|
19339
19740
|
spec(
|
|
19340
19741
|
"DEVSQ",
|
|
19341
|
-
|
|
19742
|
+
C25,
|
|
19342
19743
|
"DEVSQ(number1, ...)",
|
|
19343
19744
|
"The sum of squared deviations from the mean.",
|
|
19344
19745
|
1,
|
|
@@ -19351,7 +19752,7 @@ var STATISTICAL_SHAPE = [
|
|
|
19351
19752
|
),
|
|
19352
19753
|
spec(
|
|
19353
19754
|
"KURT",
|
|
19354
|
-
|
|
19755
|
+
C25,
|
|
19355
19756
|
"KURT(number1, ...)",
|
|
19356
19757
|
"The kurtosis of a data set.",
|
|
19357
19758
|
1,
|
|
@@ -19367,7 +19768,7 @@ var STATISTICAL_SHAPE = [
|
|
|
19367
19768
|
),
|
|
19368
19769
|
spec(
|
|
19369
19770
|
"SKEW",
|
|
19370
|
-
|
|
19771
|
+
C25,
|
|
19371
19772
|
"SKEW(number1, ...)",
|
|
19372
19773
|
"The skewness of a distribution.",
|
|
19373
19774
|
1,
|
|
@@ -19382,7 +19783,7 @@ var STATISTICAL_SHAPE = [
|
|
|
19382
19783
|
),
|
|
19383
19784
|
spec(
|
|
19384
19785
|
"SKEW.P",
|
|
19385
|
-
|
|
19786
|
+
C25,
|
|
19386
19787
|
"SKEW.P(number1, ...)",
|
|
19387
19788
|
"The population skewness.",
|
|
19388
19789
|
1,
|
|
@@ -19398,7 +19799,7 @@ var STATISTICAL_SHAPE = [
|
|
|
19398
19799
|
),
|
|
19399
19800
|
numeric(
|
|
19400
19801
|
"STANDARDIZE",
|
|
19401
|
-
|
|
19802
|
+
C25,
|
|
19402
19803
|
"STANDARDIZE(x, mean, standard_dev)",
|
|
19403
19804
|
"A normalized value.",
|
|
19404
19805
|
3,
|
|
@@ -19410,7 +19811,7 @@ var STATISTICAL_SHAPE = [
|
|
|
19410
19811
|
),
|
|
19411
19812
|
spec(
|
|
19412
19813
|
"TRIMMEAN",
|
|
19413
|
-
|
|
19814
|
+
C25,
|
|
19414
19815
|
"TRIMMEAN(array, percent)",
|
|
19415
19816
|
"The mean of the interior of a data set.",
|
|
19416
19817
|
2,
|
|
@@ -19426,7 +19827,7 @@ var STATISTICAL_SHAPE = [
|
|
|
19426
19827
|
),
|
|
19427
19828
|
spec(
|
|
19428
19829
|
"FREQUENCY",
|
|
19429
|
-
|
|
19830
|
+
C25,
|
|
19430
19831
|
"FREQUENCY(data_array, bins_array)",
|
|
19431
19832
|
"How often values occur within ranges, as a vertical array.",
|
|
19432
19833
|
2,
|
|
@@ -19436,7 +19837,7 @@ var STATISTICAL_SHAPE = [
|
|
|
19436
19837
|
),
|
|
19437
19838
|
numeric(
|
|
19438
19839
|
"PERMUT",
|
|
19439
|
-
|
|
19840
|
+
C25,
|
|
19440
19841
|
"PERMUT(number, number_chosen)",
|
|
19441
19842
|
"The number of permutations.",
|
|
19442
19843
|
2,
|
|
@@ -19452,7 +19853,7 @@ var STATISTICAL_SHAPE = [
|
|
|
19452
19853
|
),
|
|
19453
19854
|
numeric(
|
|
19454
19855
|
"PERMUTATIONA",
|
|
19455
|
-
|
|
19856
|
+
C25,
|
|
19456
19857
|
"PERMUTATIONA(number, number_chosen)",
|
|
19457
19858
|
"Permutations with repetitions.",
|
|
19458
19859
|
2,
|
|
@@ -19462,26 +19863,26 @@ var STATISTICAL_SHAPE = [
|
|
|
19462
19863
|
return Math.pow(Math.trunc(n), Math.trunc(k ?? 0));
|
|
19463
19864
|
}
|
|
19464
19865
|
),
|
|
19465
|
-
numeric("FISHER",
|
|
19866
|
+
numeric("FISHER", C25, "FISHER(x)", "The Fisher transformation.", 1, 1, (x) => {
|
|
19466
19867
|
if (x <= -1 || x >= 1) fail(ERR.NUM);
|
|
19467
19868
|
return 0.5 * Math.log((1 + x) / (1 - x));
|
|
19468
19869
|
}),
|
|
19469
19870
|
numeric(
|
|
19470
19871
|
"FISHERINV",
|
|
19471
|
-
|
|
19872
|
+
C25,
|
|
19472
19873
|
"FISHERINV(y)",
|
|
19473
19874
|
"The inverse of the Fisher transformation.",
|
|
19474
19875
|
1,
|
|
19475
19876
|
1,
|
|
19476
19877
|
(y) => Math.tanh(y)
|
|
19477
19878
|
),
|
|
19478
|
-
numeric("GAMMA",
|
|
19879
|
+
numeric("GAMMA", C25, "GAMMA(number)", "The gamma function value.", 1, 1, (x) => {
|
|
19479
19880
|
if (x <= 0 && Number.isInteger(x)) fail(ERR.NUM);
|
|
19480
19881
|
return gamma(x);
|
|
19481
19882
|
}),
|
|
19482
19883
|
numeric(
|
|
19483
19884
|
"GAMMALN",
|
|
19484
|
-
|
|
19885
|
+
C25,
|
|
19485
19886
|
"GAMMALN(x)",
|
|
19486
19887
|
"The natural logarithm of the gamma function.",
|
|
19487
19888
|
1,
|
|
@@ -19490,7 +19891,7 @@ var STATISTICAL_SHAPE = [
|
|
|
19490
19891
|
),
|
|
19491
19892
|
numeric(
|
|
19492
19893
|
"GAMMALN.PRECISE",
|
|
19493
|
-
|
|
19894
|
+
C25,
|
|
19494
19895
|
"GAMMALN.PRECISE(x)",
|
|
19495
19896
|
"The natural logarithm of the gamma function.",
|
|
19496
19897
|
1,
|
|
@@ -19500,7 +19901,7 @@ var STATISTICAL_SHAPE = [
|
|
|
19500
19901
|
];
|
|
19501
19902
|
|
|
19502
19903
|
// src/xlsx/formula/functions/statistical-more.ts
|
|
19503
|
-
var
|
|
19904
|
+
var C26 = "Statistical";
|
|
19504
19905
|
function pairedNumbers(ctx, a, b) {
|
|
19505
19906
|
const ma = ctx.toMatrix(a).flat();
|
|
19506
19907
|
const mb = ctx.toMatrix(b).flat();
|
|
@@ -19521,7 +19922,7 @@ function pairedNumbers(ctx, a, b) {
|
|
|
19521
19922
|
}
|
|
19522
19923
|
var pairFn = (name, description, syntax, fn) => spec(
|
|
19523
19924
|
name,
|
|
19524
|
-
|
|
19925
|
+
C26,
|
|
19525
19926
|
syntax,
|
|
19526
19927
|
description,
|
|
19527
19928
|
2,
|
|
@@ -19536,7 +19937,7 @@ var STATISTICAL_MORE = [
|
|
|
19536
19937
|
...STATISTICAL_SHAPE,
|
|
19537
19938
|
spec(
|
|
19538
19939
|
"MODE.MULT",
|
|
19539
|
-
|
|
19940
|
+
C26,
|
|
19540
19941
|
"MODE.MULT(number1, [number2], ...)",
|
|
19541
19942
|
"A vertical array of the most frequent values.",
|
|
19542
19943
|
1,
|
|
@@ -19618,7 +20019,7 @@ var STATISTICAL_MORE = [
|
|
|
19618
20019
|
...["FORECAST", "FORECAST.LINEAR"].map(
|
|
19619
20020
|
(name) => spec(
|
|
19620
20021
|
name,
|
|
19621
|
-
|
|
20022
|
+
C26,
|
|
19622
20023
|
`${name}(x, known_ys, known_xs)`,
|
|
19623
20024
|
"Predicts a value along a linear trend.",
|
|
19624
20025
|
3,
|
|
@@ -19635,7 +20036,7 @@ var STATISTICAL_MORE = [
|
|
|
19635
20036
|
];
|
|
19636
20037
|
|
|
19637
20038
|
// src/xlsx/formula/functions/hypothesis-tests.ts
|
|
19638
|
-
var
|
|
20039
|
+
var C27 = "Statistical";
|
|
19639
20040
|
var ARRAYS = ["any"];
|
|
19640
20041
|
var numbersOf3 = (ctx, value) => collectNumbers(ctx, [value ?? null]);
|
|
19641
20042
|
function tStatistic(a, b, type) {
|
|
@@ -19720,7 +20121,7 @@ var HYPOTHESIS_TESTS = [
|
|
|
19720
20121
|
["Z.TEST", "ZTEST"],
|
|
19721
20122
|
(name) => spec(
|
|
19722
20123
|
name,
|
|
19723
|
-
|
|
20124
|
+
C27,
|
|
19724
20125
|
`${name}(array, x, [sigma])`,
|
|
19725
20126
|
"The one-tailed P-value of a z-test.",
|
|
19726
20127
|
2,
|
|
@@ -19739,7 +20140,7 @@ var HYPOTHESIS_TESTS = [
|
|
|
19739
20140
|
["T.TEST", "TTEST"],
|
|
19740
20141
|
(name) => spec(
|
|
19741
20142
|
name,
|
|
19742
|
-
|
|
20143
|
+
C27,
|
|
19743
20144
|
`${name}(array1, array2, tails, type)`,
|
|
19744
20145
|
"The probability associated with a Student's t-test.",
|
|
19745
20146
|
4,
|
|
@@ -19760,7 +20161,7 @@ var HYPOTHESIS_TESTS = [
|
|
|
19760
20161
|
["F.TEST", "FTEST"],
|
|
19761
20162
|
(name) => spec(
|
|
19762
20163
|
name,
|
|
19763
|
-
|
|
20164
|
+
C27,
|
|
19764
20165
|
`${name}(array1, array2)`,
|
|
19765
20166
|
"The two-tailed probability that the variances of two arrays are not different.",
|
|
19766
20167
|
2,
|
|
@@ -19773,7 +20174,7 @@ var HYPOTHESIS_TESTS = [
|
|
|
19773
20174
|
["CHISQ.TEST", "CHITEST"],
|
|
19774
20175
|
(name) => spec(
|
|
19775
20176
|
name,
|
|
19776
|
-
|
|
20177
|
+
C27,
|
|
19777
20178
|
`${name}(actual_range, expected_range)`,
|
|
19778
20179
|
"The chi-squared test of independence.",
|
|
19779
20180
|
2,
|
|
@@ -19784,7 +20185,7 @@ var HYPOTHESIS_TESTS = [
|
|
|
19784
20185
|
),
|
|
19785
20186
|
spec(
|
|
19786
20187
|
"PROB",
|
|
19787
|
-
|
|
20188
|
+
C27,
|
|
19788
20189
|
"PROB(x_range, prob_range, lower_limit, [upper_limit])",
|
|
19789
20190
|
"The probability that values in a range are between two limits.",
|
|
19790
20191
|
3,
|
|
@@ -19795,7 +20196,7 @@ var HYPOTHESIS_TESTS = [
|
|
|
19795
20196
|
];
|
|
19796
20197
|
|
|
19797
20198
|
// src/xlsx/formula/functions/statistical-spread.ts
|
|
19798
|
-
var
|
|
20199
|
+
var C28 = "Statistical";
|
|
19799
20200
|
var STATISTICAL_SPREAD = [
|
|
19800
20201
|
...[
|
|
19801
20202
|
["STDEV", true, false],
|
|
@@ -19807,7 +20208,7 @@ var STATISTICAL_SPREAD = [
|
|
|
19807
20208
|
].map(
|
|
19808
20209
|
([name, sample, a]) => spec(
|
|
19809
20210
|
name,
|
|
19810
|
-
|
|
20211
|
+
C28,
|
|
19811
20212
|
`${name}(number1, [number2], ...)`,
|
|
19812
20213
|
`The ${sample ? "sample" : "population"} standard deviation${a ? " counting logicals and text" : ""}.`,
|
|
19813
20214
|
1,
|
|
@@ -19826,7 +20227,7 @@ var STATISTICAL_SPREAD = [
|
|
|
19826
20227
|
].map(
|
|
19827
20228
|
([name, sample, a]) => spec(
|
|
19828
20229
|
name,
|
|
19829
|
-
|
|
20230
|
+
C28,
|
|
19830
20231
|
`${name}(number1, [number2], ...)`,
|
|
19831
20232
|
`The ${sample ? "sample" : "population"} variance${a ? " counting logicals and text" : ""}.`,
|
|
19832
20233
|
1,
|
|
@@ -19838,7 +20239,7 @@ var STATISTICAL_SPREAD = [
|
|
|
19838
20239
|
...["PERCENTILE", "PERCENTILE.INC", "PERCENTILE.EXC"].map(
|
|
19839
20240
|
(name) => spec(
|
|
19840
20241
|
name,
|
|
19841
|
-
|
|
20242
|
+
C28,
|
|
19842
20243
|
`${name}(array, k)`,
|
|
19843
20244
|
"The k-th percentile.",
|
|
19844
20245
|
2,
|
|
@@ -19854,7 +20255,7 @@ var STATISTICAL_SPREAD = [
|
|
|
19854
20255
|
...["QUARTILE", "QUARTILE.INC", "QUARTILE.EXC"].map(
|
|
19855
20256
|
(name) => spec(
|
|
19856
20257
|
name,
|
|
19857
|
-
|
|
20258
|
+
C28,
|
|
19858
20259
|
`${name}(array, quart)`,
|
|
19859
20260
|
"A quartile of a data set.",
|
|
19860
20261
|
2,
|
|
@@ -19866,7 +20267,7 @@ var STATISTICAL_SPREAD = [
|
|
|
19866
20267
|
...["PERCENTRANK", "PERCENTRANK.INC", "PERCENTRANK.EXC"].map(
|
|
19867
20268
|
(name) => spec(
|
|
19868
20269
|
name,
|
|
19869
|
-
|
|
20270
|
+
C28,
|
|
19870
20271
|
`${name}(array, x, [significance])`,
|
|
19871
20272
|
"The rank of a value as a percentage of the data set.",
|
|
19872
20273
|
2,
|
|
@@ -19883,7 +20284,7 @@ var STATISTICAL_SPREAD = [
|
|
|
19883
20284
|
];
|
|
19884
20285
|
|
|
19885
20286
|
// src/xlsx/formula/functions/statistical-count.ts
|
|
19886
|
-
var
|
|
20287
|
+
var C29 = "Statistical";
|
|
19887
20288
|
function count(ctx, args) {
|
|
19888
20289
|
let n = 0;
|
|
19889
20290
|
for (const arg of args) {
|
|
@@ -19949,7 +20350,7 @@ function countIf(ctx, range, criteria) {
|
|
|
19949
20350
|
var COUNT_FUNCTIONS = [
|
|
19950
20351
|
spec(
|
|
19951
20352
|
"COUNT",
|
|
19952
|
-
|
|
20353
|
+
C29,
|
|
19953
20354
|
"COUNT(value1, [value2], ...)",
|
|
19954
20355
|
"Counts the numbers in the arguments.",
|
|
19955
20356
|
0,
|
|
@@ -19959,7 +20360,7 @@ var COUNT_FUNCTIONS = [
|
|
|
19959
20360
|
),
|
|
19960
20361
|
spec(
|
|
19961
20362
|
"COUNTA",
|
|
19962
|
-
|
|
20363
|
+
C29,
|
|
19963
20364
|
"COUNTA(value1, [value2], ...)",
|
|
19964
20365
|
"Counts the non-empty values.",
|
|
19965
20366
|
1,
|
|
@@ -19969,7 +20370,7 @@ var COUNT_FUNCTIONS = [
|
|
|
19969
20370
|
),
|
|
19970
20371
|
spec(
|
|
19971
20372
|
"COUNTBLANK",
|
|
19972
|
-
|
|
20373
|
+
C29,
|
|
19973
20374
|
"COUNTBLANK(range)",
|
|
19974
20375
|
"Counts the empty cells in a range.",
|
|
19975
20376
|
1,
|
|
@@ -19979,7 +20380,7 @@ var COUNT_FUNCTIONS = [
|
|
|
19979
20380
|
),
|
|
19980
20381
|
spec(
|
|
19981
20382
|
"COUNTIF",
|
|
19982
|
-
|
|
20383
|
+
C29,
|
|
19983
20384
|
"COUNTIF(range, criteria)",
|
|
19984
20385
|
"Counts the cells that meet a criterion.",
|
|
19985
20386
|
2,
|
|
@@ -19989,7 +20390,7 @@ var COUNT_FUNCTIONS = [
|
|
|
19989
20390
|
),
|
|
19990
20391
|
spec(
|
|
19991
20392
|
"COUNTIFS",
|
|
19992
|
-
|
|
20393
|
+
C29,
|
|
19993
20394
|
"COUNTIFS(criteria_range1, criteria1, ...)",
|
|
19994
20395
|
"Counts the cells that meet several criteria.",
|
|
19995
20396
|
2,
|
|
@@ -20002,7 +20403,7 @@ var COUNT_FUNCTIONS = [
|
|
|
20002
20403
|
),
|
|
20003
20404
|
spec(
|
|
20004
20405
|
"AVERAGE",
|
|
20005
|
-
|
|
20406
|
+
C29,
|
|
20006
20407
|
"AVERAGE(number1, [number2], ...)",
|
|
20007
20408
|
"The arithmetic mean.",
|
|
20008
20409
|
1,
|
|
@@ -20013,7 +20414,7 @@ var COUNT_FUNCTIONS = [
|
|
|
20013
20414
|
];
|
|
20014
20415
|
|
|
20015
20416
|
// src/xlsx/formula/functions/statistical.ts
|
|
20016
|
-
var
|
|
20417
|
+
var C30 = "Statistical";
|
|
20017
20418
|
var numbersOf4 = (values2) => values2.filter((v) => typeof v === "number");
|
|
20018
20419
|
var extreme2 = extreme;
|
|
20019
20420
|
var STATISTICAL_FUNCTIONS = [
|
|
@@ -20024,7 +20425,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
20024
20425
|
...COUNT_FUNCTIONS,
|
|
20025
20426
|
spec(
|
|
20026
20427
|
"AVERAGEA",
|
|
20027
|
-
|
|
20428
|
+
C30,
|
|
20028
20429
|
"AVERAGEA(value1, [value2], ...)",
|
|
20029
20430
|
"The mean counting text as 0 and logicals.",
|
|
20030
20431
|
1,
|
|
@@ -20034,7 +20435,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
20034
20435
|
),
|
|
20035
20436
|
spec(
|
|
20036
20437
|
"AVERAGEIF",
|
|
20037
|
-
|
|
20438
|
+
C30,
|
|
20038
20439
|
"AVERAGEIF(range, criteria, [average_range])",
|
|
20039
20440
|
"The mean of the cells that meet a criterion.",
|
|
20040
20441
|
2,
|
|
@@ -20053,7 +20454,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
20053
20454
|
),
|
|
20054
20455
|
spec(
|
|
20055
20456
|
"AVERAGEIFS",
|
|
20056
|
-
|
|
20457
|
+
C30,
|
|
20057
20458
|
"AVERAGEIFS(average_range, criteria_range1, criteria1, ...)",
|
|
20058
20459
|
"The mean of the cells that meet several criteria.",
|
|
20059
20460
|
3,
|
|
@@ -20067,7 +20468,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
20067
20468
|
),
|
|
20068
20469
|
spec(
|
|
20069
20470
|
"MAX",
|
|
20070
|
-
|
|
20471
|
+
C30,
|
|
20071
20472
|
"MAX(number1, [number2], ...)",
|
|
20072
20473
|
"The largest value.",
|
|
20073
20474
|
1,
|
|
@@ -20077,7 +20478,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
20077
20478
|
),
|
|
20078
20479
|
spec(
|
|
20079
20480
|
"MIN",
|
|
20080
|
-
|
|
20481
|
+
C30,
|
|
20081
20482
|
"MIN(number1, [number2], ...)",
|
|
20082
20483
|
"The smallest value.",
|
|
20083
20484
|
1,
|
|
@@ -20087,7 +20488,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
20087
20488
|
),
|
|
20088
20489
|
spec(
|
|
20089
20490
|
"MAXA",
|
|
20090
|
-
|
|
20491
|
+
C30,
|
|
20091
20492
|
"MAXA(value1, [value2], ...)",
|
|
20092
20493
|
"The largest value counting logicals and text.",
|
|
20093
20494
|
1,
|
|
@@ -20097,7 +20498,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
20097
20498
|
),
|
|
20098
20499
|
spec(
|
|
20099
20500
|
"MINA",
|
|
20100
|
-
|
|
20501
|
+
C30,
|
|
20101
20502
|
"MINA(value1, [value2], ...)",
|
|
20102
20503
|
"The smallest value counting logicals and text.",
|
|
20103
20504
|
1,
|
|
@@ -20107,7 +20508,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
20107
20508
|
),
|
|
20108
20509
|
spec(
|
|
20109
20510
|
"MAXIFS",
|
|
20110
|
-
|
|
20511
|
+
C30,
|
|
20111
20512
|
"MAXIFS(max_range, criteria_range1, criteria1, ...)",
|
|
20112
20513
|
"The largest value meeting criteria.",
|
|
20113
20514
|
3,
|
|
@@ -20121,7 +20522,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
20121
20522
|
),
|
|
20122
20523
|
spec(
|
|
20123
20524
|
"MINIFS",
|
|
20124
|
-
|
|
20525
|
+
C30,
|
|
20125
20526
|
"MINIFS(min_range, criteria_range1, criteria1, ...)",
|
|
20126
20527
|
"The smallest value meeting criteria.",
|
|
20127
20528
|
3,
|
|
@@ -20135,7 +20536,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
20135
20536
|
),
|
|
20136
20537
|
spec(
|
|
20137
20538
|
"MEDIAN",
|
|
20138
|
-
|
|
20539
|
+
C30,
|
|
20139
20540
|
"MEDIAN(number1, [number2], ...)",
|
|
20140
20541
|
"The median.",
|
|
20141
20542
|
1,
|
|
@@ -20145,7 +20546,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
20145
20546
|
),
|
|
20146
20547
|
spec(
|
|
20147
20548
|
"MODE",
|
|
20148
|
-
|
|
20549
|
+
C30,
|
|
20149
20550
|
"MODE(number1, [number2], ...)",
|
|
20150
20551
|
"The most frequent value.",
|
|
20151
20552
|
1,
|
|
@@ -20155,7 +20556,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
20155
20556
|
),
|
|
20156
20557
|
spec(
|
|
20157
20558
|
"MODE.SNGL",
|
|
20158
|
-
|
|
20559
|
+
C30,
|
|
20159
20560
|
"MODE.SNGL(number1, [number2], ...)",
|
|
20160
20561
|
"The most frequent value.",
|
|
20161
20562
|
1,
|
|
@@ -20165,7 +20566,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
20165
20566
|
),
|
|
20166
20567
|
spec(
|
|
20167
20568
|
"LARGE",
|
|
20168
|
-
|
|
20569
|
+
C30,
|
|
20169
20570
|
"LARGE(array, k)",
|
|
20170
20571
|
"The k-th largest value.",
|
|
20171
20572
|
2,
|
|
@@ -20175,7 +20576,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
20175
20576
|
),
|
|
20176
20577
|
spec(
|
|
20177
20578
|
"SMALL",
|
|
20178
|
-
|
|
20579
|
+
C30,
|
|
20179
20580
|
"SMALL(array, k)",
|
|
20180
20581
|
"The k-th smallest value.",
|
|
20181
20582
|
2,
|
|
@@ -20186,7 +20587,7 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
20186
20587
|
...["RANK", "RANK.EQ", "RANK.AVG"].map(
|
|
20187
20588
|
(name) => spec(
|
|
20188
20589
|
name,
|
|
20189
|
-
|
|
20590
|
+
C30,
|
|
20190
20591
|
`${name}(number, ref, [order])`,
|
|
20191
20592
|
"The rank of a number in a list.",
|
|
20192
20593
|
2,
|
|
@@ -20203,11 +20604,11 @@ var STATISTICAL_FUNCTIONS = [
|
|
|
20203
20604
|
];
|
|
20204
20605
|
|
|
20205
20606
|
// src/xlsx/formula/functions/distributions-more.ts
|
|
20206
|
-
var
|
|
20607
|
+
var C31 = "Statistical";
|
|
20207
20608
|
var DISTRIBUTION_MORE = [
|
|
20208
20609
|
numeric(
|
|
20209
20610
|
"T.DIST",
|
|
20210
|
-
|
|
20611
|
+
C31,
|
|
20211
20612
|
"T.DIST(x, deg_freedom, cumulative)",
|
|
20212
20613
|
"Student's left-tailed t-distribution.",
|
|
20213
20614
|
3,
|
|
@@ -20219,7 +20620,7 @@ var DISTRIBUTION_MORE = [
|
|
|
20219
20620
|
),
|
|
20220
20621
|
numeric(
|
|
20221
20622
|
"T.DIST.RT",
|
|
20222
|
-
|
|
20623
|
+
C31,
|
|
20223
20624
|
"T.DIST.RT(x, deg_freedom)",
|
|
20224
20625
|
"Student's right-tailed t-distribution.",
|
|
20225
20626
|
2,
|
|
@@ -20231,7 +20632,7 @@ var DISTRIBUTION_MORE = [
|
|
|
20231
20632
|
),
|
|
20232
20633
|
numeric(
|
|
20233
20634
|
"T.DIST.2T",
|
|
20234
|
-
|
|
20635
|
+
C31,
|
|
20235
20636
|
"T.DIST.2T(x, deg_freedom)",
|
|
20236
20637
|
"Student's two-tailed t-distribution.",
|
|
20237
20638
|
2,
|
|
@@ -20243,7 +20644,7 @@ var DISTRIBUTION_MORE = [
|
|
|
20243
20644
|
),
|
|
20244
20645
|
numeric(
|
|
20245
20646
|
"TDIST",
|
|
20246
|
-
|
|
20647
|
+
C31,
|
|
20247
20648
|
"TDIST(x, deg_freedom, tails)",
|
|
20248
20649
|
"Student's t-distribution.",
|
|
20249
20650
|
3,
|
|
@@ -20255,7 +20656,7 @@ var DISTRIBUTION_MORE = [
|
|
|
20255
20656
|
),
|
|
20256
20657
|
numeric(
|
|
20257
20658
|
"T.INV",
|
|
20258
|
-
|
|
20659
|
+
C31,
|
|
20259
20660
|
"T.INV(probability, deg_freedom)",
|
|
20260
20661
|
"The left-tailed inverse of Student's t-distribution.",
|
|
20261
20662
|
2,
|
|
@@ -20270,7 +20671,7 @@ var DISTRIBUTION_MORE = [
|
|
|
20270
20671
|
...["T.INV.2T", "TINV"].map(
|
|
20271
20672
|
(name) => numeric(
|
|
20272
20673
|
name,
|
|
20273
|
-
|
|
20674
|
+
C31,
|
|
20274
20675
|
`${name}(probability, deg_freedom)`,
|
|
20275
20676
|
"The two-tailed inverse of Student's t-distribution.",
|
|
20276
20677
|
2,
|
|
@@ -20283,7 +20684,7 @@ var DISTRIBUTION_MORE = [
|
|
|
20283
20684
|
),
|
|
20284
20685
|
numeric(
|
|
20285
20686
|
"CHISQ.DIST",
|
|
20286
|
-
|
|
20687
|
+
C31,
|
|
20287
20688
|
"CHISQ.DIST(x, deg_freedom, cumulative)",
|
|
20288
20689
|
"The chi-squared distribution.",
|
|
20289
20690
|
3,
|
|
@@ -20297,7 +20698,7 @@ var DISTRIBUTION_MORE = [
|
|
|
20297
20698
|
...["CHISQ.DIST.RT", "CHIDIST"].map(
|
|
20298
20699
|
(name) => numeric(
|
|
20299
20700
|
name,
|
|
20300
|
-
|
|
20701
|
+
C31,
|
|
20301
20702
|
`${name}(x, deg_freedom)`,
|
|
20302
20703
|
"The right-tailed chi-squared probability.",
|
|
20303
20704
|
2,
|
|
@@ -20310,7 +20711,7 @@ var DISTRIBUTION_MORE = [
|
|
|
20310
20711
|
),
|
|
20311
20712
|
numeric(
|
|
20312
20713
|
"CHISQ.INV",
|
|
20313
|
-
|
|
20714
|
+
C31,
|
|
20314
20715
|
"CHISQ.INV(probability, deg_freedom)",
|
|
20315
20716
|
"The inverse of the left-tailed chi-squared distribution.",
|
|
20316
20717
|
2,
|
|
@@ -20323,7 +20724,7 @@ var DISTRIBUTION_MORE = [
|
|
|
20323
20724
|
...["CHISQ.INV.RT", "CHIINV"].map(
|
|
20324
20725
|
(name) => numeric(
|
|
20325
20726
|
name,
|
|
20326
|
-
|
|
20727
|
+
C31,
|
|
20327
20728
|
`${name}(probability, deg_freedom)`,
|
|
20328
20729
|
"The inverse of the right-tailed chi-squared distribution.",
|
|
20329
20730
|
2,
|
|
@@ -20336,7 +20737,7 @@ var DISTRIBUTION_MORE = [
|
|
|
20336
20737
|
),
|
|
20337
20738
|
numeric(
|
|
20338
20739
|
"BETA.DIST",
|
|
20339
|
-
|
|
20740
|
+
C31,
|
|
20340
20741
|
"BETA.DIST(x, alpha, beta, cumulative, [A], [B])",
|
|
20341
20742
|
"The beta distribution.",
|
|
20342
20743
|
4,
|
|
@@ -20344,7 +20745,7 @@ var DISTRIBUTION_MORE = [
|
|
|
20344
20745
|
(x, a, b, c2, lo, hi) => {
|
|
20345
20746
|
const A = lo ?? 0;
|
|
20346
20747
|
const B = hi ?? 1;
|
|
20347
|
-
|
|
20748
|
+
positive2(a, b);
|
|
20348
20749
|
if (x < A || x > B || A === B) fail(ERR.NUM);
|
|
20349
20750
|
const t = (x - A) / (B - A);
|
|
20350
20751
|
const al = a ?? 1;
|
|
@@ -20356,7 +20757,7 @@ var DISTRIBUTION_MORE = [
|
|
|
20356
20757
|
),
|
|
20357
20758
|
numeric(
|
|
20358
20759
|
"NEGBINOM.DIST",
|
|
20359
|
-
|
|
20760
|
+
C31,
|
|
20360
20761
|
"NEGBINOM.DIST(number_f, number_s, probability_s, cumulative)",
|
|
20361
20762
|
"The negative binomial distribution.",
|
|
20362
20763
|
4,
|
|
@@ -20375,7 +20776,7 @@ var DISTRIBUTION_MORE = [
|
|
|
20375
20776
|
),
|
|
20376
20777
|
numeric(
|
|
20377
20778
|
"HYPGEOM.DIST",
|
|
20378
|
-
|
|
20779
|
+
C31,
|
|
20379
20780
|
"HYPGEOM.DIST(sample_s, number_sample, population_s, number_pop, cumulative)",
|
|
20380
20781
|
"The hypergeometric distribution.",
|
|
20381
20782
|
5,
|
|
@@ -20396,13 +20797,13 @@ var DISTRIBUTION_MORE = [
|
|
|
20396
20797
|
];
|
|
20397
20798
|
|
|
20398
20799
|
// src/xlsx/formula/functions/distributions.ts
|
|
20399
|
-
var
|
|
20800
|
+
var C32 = "Statistical";
|
|
20400
20801
|
var DISTRIBUTION_FUNCTIONS = [
|
|
20401
20802
|
...DISTRIBUTION_MORE,
|
|
20402
20803
|
...DISTRIBUTION_F,
|
|
20403
20804
|
numeric(
|
|
20404
20805
|
"NORM.DIST",
|
|
20405
|
-
|
|
20806
|
+
C32,
|
|
20406
20807
|
"NORM.DIST(x, mean, standard_dev, cumulative)",
|
|
20407
20808
|
"The normal distribution.",
|
|
20408
20809
|
4,
|
|
@@ -20411,7 +20812,7 @@ var DISTRIBUTION_FUNCTIONS = [
|
|
|
20411
20812
|
),
|
|
20412
20813
|
numeric(
|
|
20413
20814
|
"NORMDIST",
|
|
20414
|
-
|
|
20815
|
+
C32,
|
|
20415
20816
|
"NORMDIST(x, mean, standard_dev, cumulative)",
|
|
20416
20817
|
"The normal distribution.",
|
|
20417
20818
|
4,
|
|
@@ -20420,7 +20821,7 @@ var DISTRIBUTION_FUNCTIONS = [
|
|
|
20420
20821
|
),
|
|
20421
20822
|
numeric(
|
|
20422
20823
|
"NORM.S.DIST",
|
|
20423
|
-
|
|
20824
|
+
C32,
|
|
20424
20825
|
"NORM.S.DIST(z, cumulative)",
|
|
20425
20826
|
"The standard normal distribution.",
|
|
20426
20827
|
2,
|
|
@@ -20429,7 +20830,7 @@ var DISTRIBUTION_FUNCTIONS = [
|
|
|
20429
20830
|
),
|
|
20430
20831
|
numeric(
|
|
20431
20832
|
"NORMSDIST",
|
|
20432
|
-
|
|
20833
|
+
C32,
|
|
20433
20834
|
"NORMSDIST(z)",
|
|
20434
20835
|
"The standard normal cumulative distribution.",
|
|
20435
20836
|
1,
|
|
@@ -20438,31 +20839,31 @@ var DISTRIBUTION_FUNCTIONS = [
|
|
|
20438
20839
|
),
|
|
20439
20840
|
numeric(
|
|
20440
20841
|
"NORM.INV",
|
|
20441
|
-
|
|
20842
|
+
C32,
|
|
20442
20843
|
"NORM.INV(probability, mean, standard_dev)",
|
|
20443
20844
|
"The inverse of the normal cumulative distribution.",
|
|
20444
20845
|
3,
|
|
20445
20846
|
3,
|
|
20446
20847
|
(p, m, s) => {
|
|
20447
|
-
|
|
20848
|
+
positive2(s);
|
|
20448
20849
|
return (m ?? 0) + (s ?? 1) * normInv(p);
|
|
20449
20850
|
}
|
|
20450
20851
|
),
|
|
20451
20852
|
numeric(
|
|
20452
20853
|
"NORMINV",
|
|
20453
|
-
|
|
20854
|
+
C32,
|
|
20454
20855
|
"NORMINV(probability, mean, standard_dev)",
|
|
20455
20856
|
"The inverse of the normal cumulative distribution.",
|
|
20456
20857
|
3,
|
|
20457
20858
|
3,
|
|
20458
20859
|
(p, m, s) => {
|
|
20459
|
-
|
|
20860
|
+
positive2(s);
|
|
20460
20861
|
return (m ?? 0) + (s ?? 1) * normInv(p);
|
|
20461
20862
|
}
|
|
20462
20863
|
),
|
|
20463
20864
|
numeric(
|
|
20464
20865
|
"NORM.S.INV",
|
|
20465
|
-
|
|
20866
|
+
C32,
|
|
20466
20867
|
"NORM.S.INV(probability)",
|
|
20467
20868
|
"The inverse of the standard normal distribution.",
|
|
20468
20869
|
1,
|
|
@@ -20471,17 +20872,17 @@ var DISTRIBUTION_FUNCTIONS = [
|
|
|
20471
20872
|
),
|
|
20472
20873
|
numeric(
|
|
20473
20874
|
"NORMSINV",
|
|
20474
|
-
|
|
20875
|
+
C32,
|
|
20475
20876
|
"NORMSINV(probability)",
|
|
20476
20877
|
"The inverse of the standard normal distribution.",
|
|
20477
20878
|
1,
|
|
20478
20879
|
1,
|
|
20479
20880
|
normInv
|
|
20480
20881
|
),
|
|
20481
|
-
numeric("PHI",
|
|
20882
|
+
numeric("PHI", C32, "PHI(x)", "The standard normal density.", 1, 1, normPdf),
|
|
20482
20883
|
numeric(
|
|
20483
20884
|
"GAUSS",
|
|
20484
|
-
|
|
20885
|
+
C32,
|
|
20485
20886
|
"GAUSS(z)",
|
|
20486
20887
|
"The probability between the mean and z standard deviations.",
|
|
20487
20888
|
1,
|
|
@@ -20519,14 +20920,14 @@ var DISTRIBUTION_FUNCTIONS = [
|
|
|
20519
20920
|
...["CONFIDENCE", "CONFIDENCE.NORM"].map(
|
|
20520
20921
|
(name) => numeric(
|
|
20521
20922
|
name,
|
|
20522
|
-
|
|
20923
|
+
C32,
|
|
20523
20924
|
`${name}(alpha, standard_dev, size)`,
|
|
20524
20925
|
"The confidence interval for a population mean (normal).",
|
|
20525
20926
|
3,
|
|
20526
20927
|
3,
|
|
20527
20928
|
(a, s, n) => {
|
|
20528
20929
|
probability(a);
|
|
20529
|
-
|
|
20930
|
+
positive2(s);
|
|
20530
20931
|
if ((n ?? 0) < 1) fail(ERR.NUM);
|
|
20531
20932
|
return normInv(1 - a / 2) * (s ?? 1) / Math.sqrt(Math.trunc(n ?? 1));
|
|
20532
20933
|
}
|
|
@@ -20534,14 +20935,14 @@ var DISTRIBUTION_FUNCTIONS = [
|
|
|
20534
20935
|
),
|
|
20535
20936
|
numeric(
|
|
20536
20937
|
"CONFIDENCE.T",
|
|
20537
|
-
|
|
20938
|
+
C32,
|
|
20538
20939
|
"CONFIDENCE.T(alpha, standard_dev, size)",
|
|
20539
20940
|
"The confidence interval for a population mean (Student's t).",
|
|
20540
20941
|
3,
|
|
20541
20942
|
3,
|
|
20542
20943
|
(a, s, n) => {
|
|
20543
20944
|
probability(a);
|
|
20544
|
-
|
|
20945
|
+
positive2(s);
|
|
20545
20946
|
const size = Math.trunc(n ?? 1);
|
|
20546
20947
|
if (size < 2) fail(ERR.DIV0);
|
|
20547
20948
|
return invert((t) => tCdf(t, size - 1), 1 - a / 2, 0, 10) * (s ?? 1) / Math.sqrt(size);
|
|
@@ -20550,7 +20951,7 @@ var DISTRIBUTION_FUNCTIONS = [
|
|
|
20550
20951
|
...["BINOM.DIST", "BINOMDIST"].map(
|
|
20551
20952
|
(name) => numeric(
|
|
20552
20953
|
name,
|
|
20553
|
-
|
|
20954
|
+
C32,
|
|
20554
20955
|
`${name}(number_s, trials, probability_s, cumulative)`,
|
|
20555
20956
|
"The binomial distribution probability.",
|
|
20556
20957
|
4,
|
|
@@ -20561,7 +20962,7 @@ var DISTRIBUTION_FUNCTIONS = [
|
|
|
20561
20962
|
...["POISSON.DIST", "POISSON"].map(
|
|
20562
20963
|
(name) => numeric(
|
|
20563
20964
|
name,
|
|
20564
|
-
|
|
20965
|
+
C32,
|
|
20565
20966
|
`${name}(x, mean, cumulative)`,
|
|
20566
20967
|
"The Poisson distribution.",
|
|
20567
20968
|
3,
|
|
@@ -20572,54 +20973,54 @@ var DISTRIBUTION_FUNCTIONS = [
|
|
|
20572
20973
|
...["EXPON.DIST", "EXPONDIST"].map(
|
|
20573
20974
|
(name) => numeric(
|
|
20574
20975
|
name,
|
|
20575
|
-
|
|
20976
|
+
C32,
|
|
20576
20977
|
`${name}(x, lambda, cumulative)`,
|
|
20577
20978
|
"The exponential distribution.",
|
|
20578
20979
|
3,
|
|
20579
20980
|
3,
|
|
20580
20981
|
(x, l, c2) => {
|
|
20581
20982
|
if (x < 0) fail(ERR.NUM);
|
|
20582
|
-
|
|
20983
|
+
positive2(l);
|
|
20583
20984
|
return c2 ? 1 - Math.exp(-(l ?? 1) * x) : (l ?? 1) * Math.exp(-(l ?? 1) * x);
|
|
20584
20985
|
}
|
|
20585
20986
|
)
|
|
20586
20987
|
),
|
|
20587
20988
|
numeric(
|
|
20588
20989
|
"LOGNORM.DIST",
|
|
20589
|
-
|
|
20990
|
+
C32,
|
|
20590
20991
|
"LOGNORM.DIST(x, mean, standard_dev, cumulative)",
|
|
20591
20992
|
"The lognormal distribution.",
|
|
20592
20993
|
4,
|
|
20593
20994
|
4,
|
|
20594
20995
|
(x, m, s, c2) => {
|
|
20595
|
-
|
|
20996
|
+
positive2(x, s);
|
|
20596
20997
|
const z = (Math.log(x) - (m ?? 0)) / (s ?? 1);
|
|
20597
20998
|
return c2 ? normCdf(z) : normPdf(z) / (x * (s ?? 1));
|
|
20598
20999
|
}
|
|
20599
21000
|
),
|
|
20600
21001
|
numeric(
|
|
20601
21002
|
"LOGNORM.INV",
|
|
20602
|
-
|
|
21003
|
+
C32,
|
|
20603
21004
|
"LOGNORM.INV(probability, mean, standard_dev)",
|
|
20604
21005
|
"The inverse of the lognormal distribution.",
|
|
20605
21006
|
3,
|
|
20606
21007
|
3,
|
|
20607
21008
|
(p, m, s) => {
|
|
20608
|
-
|
|
21009
|
+
positive2(s);
|
|
20609
21010
|
return Math.exp((m ?? 0) + (s ?? 1) * normInv(p));
|
|
20610
21011
|
}
|
|
20611
21012
|
),
|
|
20612
21013
|
...["WEIBULL.DIST", "WEIBULL"].map(
|
|
20613
21014
|
(name) => numeric(
|
|
20614
21015
|
name,
|
|
20615
|
-
|
|
21016
|
+
C32,
|
|
20616
21017
|
`${name}(x, alpha, beta, cumulative)`,
|
|
20617
21018
|
"The Weibull distribution.",
|
|
20618
21019
|
4,
|
|
20619
21020
|
4,
|
|
20620
21021
|
(x, a, b, c2) => {
|
|
20621
21022
|
if (x < 0) fail(ERR.NUM);
|
|
20622
|
-
|
|
21023
|
+
positive2(a, b);
|
|
20623
21024
|
const al = a ?? 1;
|
|
20624
21025
|
const be = b ?? 1;
|
|
20625
21026
|
return c2 ? 1 - Math.exp(-Math.pow(x / be, al)) : al / Math.pow(be, al) * Math.pow(x, al - 1) * Math.exp(-Math.pow(x / be, al));
|
|
@@ -20628,14 +21029,14 @@ var DISTRIBUTION_FUNCTIONS = [
|
|
|
20628
21029
|
),
|
|
20629
21030
|
numeric(
|
|
20630
21031
|
"GAMMA.DIST",
|
|
20631
|
-
|
|
21032
|
+
C32,
|
|
20632
21033
|
"GAMMA.DIST(x, alpha, beta, cumulative)",
|
|
20633
21034
|
"The gamma distribution.",
|
|
20634
21035
|
4,
|
|
20635
21036
|
4,
|
|
20636
21037
|
(x, a, b, c2) => {
|
|
20637
21038
|
if (x < 0) fail(ERR.NUM);
|
|
20638
|
-
|
|
21039
|
+
positive2(a, b);
|
|
20639
21040
|
const al = a ?? 1;
|
|
20640
21041
|
const be = b ?? 1;
|
|
20641
21042
|
return c2 ? gammaP(al, x / be) : Math.exp((al - 1) * Math.log(x) - x / be - gammaLn(al) - al * Math.log(be));
|
|
@@ -20644,7 +21045,7 @@ var DISTRIBUTION_FUNCTIONS = [
|
|
|
20644
21045
|
];
|
|
20645
21046
|
|
|
20646
21047
|
// src/xlsx/formula/functions/text-convert.ts
|
|
20647
|
-
var
|
|
21048
|
+
var C33 = "Text";
|
|
20648
21049
|
var CP1252 = {
|
|
20649
21050
|
128: 8364,
|
|
20650
21051
|
130: 8218,
|
|
@@ -20689,7 +21090,7 @@ function fixed(value, decimals, commas) {
|
|
|
20689
21090
|
var TEXT_CONVERT = [
|
|
20690
21091
|
spec(
|
|
20691
21092
|
"TEXT",
|
|
20692
|
-
|
|
21093
|
+
C33,
|
|
20693
21094
|
"TEXT(value, format_text)",
|
|
20694
21095
|
"Formats a value with a number format.",
|
|
20695
21096
|
2,
|
|
@@ -20702,7 +21103,7 @@ var TEXT_CONVERT = [
|
|
|
20702
21103
|
return formatValue(value, str(args[1]), { date1904: ctx.date1904 }).text;
|
|
20703
21104
|
}
|
|
20704
21105
|
),
|
|
20705
|
-
spec("VALUE",
|
|
21106
|
+
spec("VALUE", C33, "VALUE(text)", "Converts text to a number.", 1, 1, (args) => {
|
|
20706
21107
|
const v = scalar(args[0]);
|
|
20707
21108
|
if (typeof v === "number") return v;
|
|
20708
21109
|
if (v === null) return 0;
|
|
@@ -20712,7 +21113,7 @@ var TEXT_CONVERT = [
|
|
|
20712
21113
|
}),
|
|
20713
21114
|
spec(
|
|
20714
21115
|
"NUMBERVALUE",
|
|
20715
|
-
|
|
21116
|
+
C33,
|
|
20716
21117
|
"NUMBERVALUE(text, [decimal_separator], [group_separator])",
|
|
20717
21118
|
"Converts text to a number with given separators.",
|
|
20718
21119
|
1,
|
|
@@ -20739,7 +21140,7 @@ var TEXT_CONVERT = [
|
|
|
20739
21140
|
),
|
|
20740
21141
|
spec(
|
|
20741
21142
|
"FIXED",
|
|
20742
|
-
|
|
21143
|
+
C33,
|
|
20743
21144
|
"FIXED(number, [decimals], [no_commas])",
|
|
20744
21145
|
"Formats a number as text with fixed decimals.",
|
|
20745
21146
|
1,
|
|
@@ -20748,7 +21149,7 @@ var TEXT_CONVERT = [
|
|
|
20748
21149
|
),
|
|
20749
21150
|
spec(
|
|
20750
21151
|
"DOLLAR",
|
|
20751
|
-
|
|
21152
|
+
C33,
|
|
20752
21153
|
"DOLLAR(number, [decimals])",
|
|
20753
21154
|
"Formats a number as currency text.",
|
|
20754
21155
|
1,
|
|
@@ -20759,28 +21160,28 @@ var TEXT_CONVERT = [
|
|
|
20759
21160
|
return value < 0 && text.replace(/[0.,]/g, "") !== "" ? `($${text})` : `$${text}`;
|
|
20760
21161
|
}
|
|
20761
21162
|
),
|
|
20762
|
-
spec("CHAR",
|
|
21163
|
+
spec("CHAR", C33, "CHAR(number)", "The character for a code (Windows-1252).", 1, 1, (args) => {
|
|
20763
21164
|
const n = int3(args[0]);
|
|
20764
21165
|
if (n < 1 || n > 255) fail(ERR.VALUE);
|
|
20765
21166
|
return String.fromCharCode(CP1252[n] ?? n);
|
|
20766
21167
|
}),
|
|
20767
|
-
spec("CODE",
|
|
21168
|
+
spec("CODE", C33, "CODE(text)", "The code of the first character (Windows-1252).", 1, 1, (args) => {
|
|
20768
21169
|
const text = str(args[0]);
|
|
20769
21170
|
if (text === "") fail(ERR.VALUE);
|
|
20770
21171
|
const code = text.charCodeAt(0);
|
|
20771
21172
|
return CP1252_REVERSE.get(code) ?? (code <= 255 ? code : 63);
|
|
20772
21173
|
}),
|
|
20773
|
-
spec("UNICHAR",
|
|
21174
|
+
spec("UNICHAR", C33, "UNICHAR(number)", "The Unicode character for a code point.", 1, 1, (args) => {
|
|
20774
21175
|
const n = int3(args[0]);
|
|
20775
21176
|
if (n < 1 || n > 1114111) fail(ERR.VALUE);
|
|
20776
21177
|
return String.fromCodePoint(n);
|
|
20777
21178
|
}),
|
|
20778
|
-
spec("UNICODE",
|
|
21179
|
+
spec("UNICODE", C33, "UNICODE(text)", "The code point of the first character.", 1, 1, (args) => {
|
|
20779
21180
|
const text = str(args[0]);
|
|
20780
21181
|
if (text === "") fail(ERR.VALUE);
|
|
20781
21182
|
return text.codePointAt(0) ?? fail(ERR.VALUE);
|
|
20782
21183
|
}),
|
|
20783
|
-
spec("T",
|
|
21184
|
+
spec("T", C33, "T(value)", "The text of a value, or empty text.", 1, 1, (args) => {
|
|
20784
21185
|
const v = scalar(args[0]);
|
|
20785
21186
|
if (isError(v)) return v;
|
|
20786
21187
|
return typeof v === "string" ? v : "";
|
|
@@ -20830,7 +21231,7 @@ function right(text, n) {
|
|
|
20830
21231
|
}
|
|
20831
21232
|
|
|
20832
21233
|
// src/xlsx/formula/functions/text.ts
|
|
20833
|
-
var
|
|
21234
|
+
var C34 = "Text";
|
|
20834
21235
|
var MAX_TEXT = 32767;
|
|
20835
21236
|
var limit = (text) => text.length > MAX_TEXT ? fail(ERR.VALUE) : text;
|
|
20836
21237
|
function find(args, insensitive) {
|
|
@@ -20863,7 +21264,7 @@ var TEXT_FUNCTIONS = [
|
|
|
20863
21264
|
...TEXT_CONVERT,
|
|
20864
21265
|
spec(
|
|
20865
21266
|
"CONCATENATE",
|
|
20866
|
-
|
|
21267
|
+
C34,
|
|
20867
21268
|
"CONCATENATE(text1, [text2], ...)",
|
|
20868
21269
|
"Joins text items.",
|
|
20869
21270
|
1,
|
|
@@ -20872,7 +21273,7 @@ var TEXT_FUNCTIONS = [
|
|
|
20872
21273
|
),
|
|
20873
21274
|
spec(
|
|
20874
21275
|
"CONCAT",
|
|
20875
|
-
|
|
21276
|
+
C34,
|
|
20876
21277
|
"CONCAT(text1, [text2], ...)",
|
|
20877
21278
|
"Joins text from items and ranges.",
|
|
20878
21279
|
1,
|
|
@@ -20882,7 +21283,7 @@ var TEXT_FUNCTIONS = [
|
|
|
20882
21283
|
),
|
|
20883
21284
|
spec(
|
|
20884
21285
|
"TEXTJOIN",
|
|
20885
|
-
|
|
21286
|
+
C34,
|
|
20886
21287
|
"TEXTJOIN(delimiter, ignore_empty, text1, ...)",
|
|
20887
21288
|
"Joins text with a delimiter.",
|
|
20888
21289
|
3,
|
|
@@ -20901,14 +21302,14 @@ var TEXT_FUNCTIONS = [
|
|
|
20901
21302
|
["any"]
|
|
20902
21303
|
),
|
|
20903
21304
|
...["LEFT", "LEFTB"].map(
|
|
20904
|
-
(name) => spec(name,
|
|
21305
|
+
(name) => spec(name, C34, `${name}(text, [num_chars])`, "The first characters of a text.", 1, 2, (args) => {
|
|
20905
21306
|
const n = optNum(args, 1, 1);
|
|
20906
21307
|
if (n < 0) fail(ERR.VALUE);
|
|
20907
21308
|
return left(str(args[0]), Math.trunc(n));
|
|
20908
21309
|
})
|
|
20909
21310
|
),
|
|
20910
21311
|
...["RIGHT", "RIGHTB"].map(
|
|
20911
|
-
(name) => spec(name,
|
|
21312
|
+
(name) => spec(name, C34, `${name}(text, [num_chars])`, "The last characters of a text.", 1, 2, (args) => {
|
|
20912
21313
|
const n = Math.trunc(optNum(args, 1, 1));
|
|
20913
21314
|
if (n < 0) fail(ERR.VALUE);
|
|
20914
21315
|
return right(str(args[0]), n);
|
|
@@ -20917,7 +21318,7 @@ var TEXT_FUNCTIONS = [
|
|
|
20917
21318
|
...["MID", "MIDB"].map(
|
|
20918
21319
|
(name) => spec(
|
|
20919
21320
|
name,
|
|
20920
|
-
|
|
21321
|
+
C34,
|
|
20921
21322
|
`${name}(text, start_num, num_chars)`,
|
|
20922
21323
|
"Characters from the middle of a text.",
|
|
20923
21324
|
3,
|
|
@@ -20933,7 +21334,7 @@ var TEXT_FUNCTIONS = [
|
|
|
20933
21334
|
...["LEN", "LENB"].map(
|
|
20934
21335
|
(name) => spec(
|
|
20935
21336
|
name,
|
|
20936
|
-
|
|
21337
|
+
C34,
|
|
20937
21338
|
`${name}(text)`,
|
|
20938
21339
|
"The number of characters in a text.",
|
|
20939
21340
|
1,
|
|
@@ -20943,7 +21344,7 @@ var TEXT_FUNCTIONS = [
|
|
|
20943
21344
|
),
|
|
20944
21345
|
spec(
|
|
20945
21346
|
"LOWER",
|
|
20946
|
-
|
|
21347
|
+
C34,
|
|
20947
21348
|
"LOWER(text)",
|
|
20948
21349
|
"Converts text to lower case.",
|
|
20949
21350
|
1,
|
|
@@ -20952,7 +21353,7 @@ var TEXT_FUNCTIONS = [
|
|
|
20952
21353
|
),
|
|
20953
21354
|
spec(
|
|
20954
21355
|
"UPPER",
|
|
20955
|
-
|
|
21356
|
+
C34,
|
|
20956
21357
|
"UPPER(text)",
|
|
20957
21358
|
"Converts text to upper case.",
|
|
20958
21359
|
1,
|
|
@@ -20961,7 +21362,7 @@ var TEXT_FUNCTIONS = [
|
|
|
20961
21362
|
),
|
|
20962
21363
|
spec(
|
|
20963
21364
|
"PROPER",
|
|
20964
|
-
|
|
21365
|
+
C34,
|
|
20965
21366
|
"PROPER(text)",
|
|
20966
21367
|
"Capitalizes the first letter of each word.",
|
|
20967
21368
|
1,
|
|
@@ -20970,7 +21371,7 @@ var TEXT_FUNCTIONS = [
|
|
|
20970
21371
|
),
|
|
20971
21372
|
spec(
|
|
20972
21373
|
"TRIM",
|
|
20973
|
-
|
|
21374
|
+
C34,
|
|
20974
21375
|
"TRIM(text)",
|
|
20975
21376
|
"Removes extra spaces.",
|
|
20976
21377
|
1,
|
|
@@ -20979,7 +21380,7 @@ var TEXT_FUNCTIONS = [
|
|
|
20979
21380
|
),
|
|
20980
21381
|
spec(
|
|
20981
21382
|
"CLEAN",
|
|
20982
|
-
|
|
21383
|
+
C34,
|
|
20983
21384
|
"CLEAN(text)",
|
|
20984
21385
|
"Removes non-printable characters.",
|
|
20985
21386
|
1,
|
|
@@ -20991,7 +21392,7 @@ var TEXT_FUNCTIONS = [
|
|
|
20991
21392
|
),
|
|
20992
21393
|
spec(
|
|
20993
21394
|
"SUBSTITUTE",
|
|
20994
|
-
|
|
21395
|
+
C34,
|
|
20995
21396
|
"SUBSTITUTE(text, old_text, new_text, [instance_num])",
|
|
20996
21397
|
"Replaces occurrences of a text.",
|
|
20997
21398
|
3,
|
|
@@ -21015,7 +21416,7 @@ var TEXT_FUNCTIONS = [
|
|
|
21015
21416
|
...["REPLACE", "REPLACEB"].map(
|
|
21016
21417
|
(name) => spec(
|
|
21017
21418
|
name,
|
|
21018
|
-
|
|
21419
|
+
C34,
|
|
21019
21420
|
`${name}(old_text, start_num, num_chars, new_text)`,
|
|
21020
21421
|
"Replaces part of a text.",
|
|
21021
21422
|
4,
|
|
@@ -21032,7 +21433,7 @@ var TEXT_FUNCTIONS = [
|
|
|
21032
21433
|
...["FIND", "FINDB"].map(
|
|
21033
21434
|
(name) => spec(
|
|
21034
21435
|
name,
|
|
21035
|
-
|
|
21436
|
+
C34,
|
|
21036
21437
|
`${name}(find_text, within_text, [start_num])`,
|
|
21037
21438
|
"The position of a text (case-sensitive).",
|
|
21038
21439
|
2,
|
|
@@ -21043,7 +21444,7 @@ var TEXT_FUNCTIONS = [
|
|
|
21043
21444
|
...["SEARCH", "SEARCHB"].map(
|
|
21044
21445
|
(name) => spec(
|
|
21045
21446
|
name,
|
|
21046
|
-
|
|
21447
|
+
C34,
|
|
21047
21448
|
`${name}(find_text, within_text, [start_num])`,
|
|
21048
21449
|
"The position of a text (wildcards, any case).",
|
|
21049
21450
|
2,
|
|
@@ -21051,7 +21452,7 @@ var TEXT_FUNCTIONS = [
|
|
|
21051
21452
|
(args) => find(args, true)
|
|
21052
21453
|
)
|
|
21053
21454
|
),
|
|
21054
|
-
spec("REPT",
|
|
21455
|
+
spec("REPT", C34, "REPT(text, number_times)", "Repeats a text.", 2, 2, (args) => {
|
|
21055
21456
|
const n = Math.trunc(num2(args[1]));
|
|
21056
21457
|
const text = str(args[0]);
|
|
21057
21458
|
if (n < 0 || text.length * n > MAX_TEXT) fail(ERR.VALUE);
|
|
@@ -21059,7 +21460,7 @@ var TEXT_FUNCTIONS = [
|
|
|
21059
21460
|
}),
|
|
21060
21461
|
spec(
|
|
21061
21462
|
"EXACT",
|
|
21062
|
-
|
|
21463
|
+
C34,
|
|
21063
21464
|
"EXACT(text1, text2)",
|
|
21064
21465
|
"Whether two texts are identical (case-sensitive).",
|
|
21065
21466
|
2,
|
|
@@ -21068,8 +21469,78 @@ var TEXT_FUNCTIONS = [
|
|
|
21068
21469
|
)
|
|
21069
21470
|
];
|
|
21070
21471
|
|
|
21472
|
+
// src/xlsx/formula/functions/text-regex.ts
|
|
21473
|
+
var C35 = "Text";
|
|
21474
|
+
function compile(pattern, caseMode2, global) {
|
|
21475
|
+
if (caseMode2 !== 0 && caseMode2 !== 1) fail(ERR.VALUE);
|
|
21476
|
+
try {
|
|
21477
|
+
return new RegExp(pattern, `${global ? "g" : ""}${caseMode2 === 1 ? "i" : ""}u`);
|
|
21478
|
+
} catch {
|
|
21479
|
+
return fail(ERR.VALUE);
|
|
21480
|
+
}
|
|
21481
|
+
}
|
|
21482
|
+
var caseMode = (args, index2) => optNum(args, index2, 0);
|
|
21483
|
+
function encodeUrl(text) {
|
|
21484
|
+
return encodeURIComponent(text).replace(
|
|
21485
|
+
/[!'()*]/g,
|
|
21486
|
+
(c2) => `%${c2.charCodeAt(0).toString(16).toUpperCase()}`
|
|
21487
|
+
);
|
|
21488
|
+
}
|
|
21489
|
+
var TEXT_REGEX_FUNCTIONS = [
|
|
21490
|
+
spec(
|
|
21491
|
+
"ENCODEURL",
|
|
21492
|
+
C35,
|
|
21493
|
+
"ENCODEURL(text)",
|
|
21494
|
+
"Percent-encodes text for use in a URL.",
|
|
21495
|
+
1,
|
|
21496
|
+
1,
|
|
21497
|
+
(args) => encodeUrl(str(args[0]))
|
|
21498
|
+
),
|
|
21499
|
+
spec(
|
|
21500
|
+
"REGEXTEST",
|
|
21501
|
+
C35,
|
|
21502
|
+
"REGEXTEST(text, pattern, [case_sensitivity])",
|
|
21503
|
+
"Whether any part of the text matches the pattern.",
|
|
21504
|
+
2,
|
|
21505
|
+
3,
|
|
21506
|
+
(args) => compile(str(args[1]), caseMode(args, 2), false).test(str(args[0]))
|
|
21507
|
+
),
|
|
21508
|
+
spec(
|
|
21509
|
+
"REGEXEXTRACT",
|
|
21510
|
+
C35,
|
|
21511
|
+
"REGEXEXTRACT(text, pattern, [return_mode], [case_sensitivity])",
|
|
21512
|
+
"The first part of the text that matches the pattern.",
|
|
21513
|
+
2,
|
|
21514
|
+
4,
|
|
21515
|
+
(args) => {
|
|
21516
|
+
if (optNum(args, 2, 0) !== 0) fail(ERR.VALUE);
|
|
21517
|
+
const match2 = compile(str(args[1]), caseMode(args, 3), false).exec(str(args[0]));
|
|
21518
|
+
return match2 ? match2[0] : fail(ERR.NA);
|
|
21519
|
+
}
|
|
21520
|
+
),
|
|
21521
|
+
spec(
|
|
21522
|
+
"REGEXREPLACE",
|
|
21523
|
+
C35,
|
|
21524
|
+
"REGEXREPLACE(text, pattern, replacement, [occurrence], [case_sensitivity])",
|
|
21525
|
+
"Replaces the parts of the text that match the pattern.",
|
|
21526
|
+
3,
|
|
21527
|
+
5,
|
|
21528
|
+
(args) => {
|
|
21529
|
+
const text = str(args[0]);
|
|
21530
|
+
const regex = compile(str(args[1]), caseMode(args, 4), true);
|
|
21531
|
+
const replacement = str(args[2]);
|
|
21532
|
+
const occurrence = args.length > 3 && args[3] !== null ? int3(args[3]) : 0;
|
|
21533
|
+
if (occurrence === 0) return text.replace(regex, replacement);
|
|
21534
|
+
const matches2 = [...text.matchAll(regex)];
|
|
21535
|
+
const picked = occurrence > 0 ? matches2[occurrence - 1] : matches2.at(occurrence);
|
|
21536
|
+
if (!picked || picked.index === void 0) return text;
|
|
21537
|
+
return text.slice(0, picked.index) + picked[0].replace(new RegExp(regex.source, regex.flags.replace("g", "")), replacement) + text.slice(picked.index + picked[0].length);
|
|
21538
|
+
}
|
|
21539
|
+
)
|
|
21540
|
+
];
|
|
21541
|
+
|
|
21071
21542
|
// src/xlsx/formula/functions/text-extra.ts
|
|
21072
|
-
var
|
|
21543
|
+
var C36 = "Text";
|
|
21073
21544
|
function delimitersOf(ctx, value) {
|
|
21074
21545
|
if (value === void 0 || value === null) return [];
|
|
21075
21546
|
return ctx.toMatrix(value).flat().map((v) => {
|
|
@@ -21135,9 +21606,10 @@ function valueToText(value, strict) {
|
|
|
21135
21606
|
return toText(value);
|
|
21136
21607
|
}
|
|
21137
21608
|
var TEXT_EXTRA_FUNCTIONS = [
|
|
21609
|
+
...TEXT_REGEX_FUNCTIONS,
|
|
21138
21610
|
spec(
|
|
21139
21611
|
"TEXTBEFORE",
|
|
21140
|
-
|
|
21612
|
+
C36,
|
|
21141
21613
|
"TEXTBEFORE(text, delimiter, [instance_num], [match_mode], [match_end], [if_not_found])",
|
|
21142
21614
|
"The text before a delimiter.",
|
|
21143
21615
|
2,
|
|
@@ -21147,7 +21619,7 @@ var TEXT_EXTRA_FUNCTIONS = [
|
|
|
21147
21619
|
),
|
|
21148
21620
|
spec(
|
|
21149
21621
|
"TEXTAFTER",
|
|
21150
|
-
|
|
21622
|
+
C36,
|
|
21151
21623
|
"TEXTAFTER(text, delimiter, [instance_num], [match_mode], [match_end], [if_not_found])",
|
|
21152
21624
|
"The text after a delimiter.",
|
|
21153
21625
|
2,
|
|
@@ -21157,7 +21629,7 @@ var TEXT_EXTRA_FUNCTIONS = [
|
|
|
21157
21629
|
),
|
|
21158
21630
|
spec(
|
|
21159
21631
|
"TEXTSPLIT",
|
|
21160
|
-
|
|
21632
|
+
C36,
|
|
21161
21633
|
"TEXTSPLIT(text, col_delimiter, [row_delimiter], [ignore_empty], [match_mode], [pad_with])",
|
|
21162
21634
|
"Splits text into an array.",
|
|
21163
21635
|
2,
|
|
@@ -21180,7 +21652,7 @@ var TEXT_EXTRA_FUNCTIONS = [
|
|
|
21180
21652
|
),
|
|
21181
21653
|
spec(
|
|
21182
21654
|
"VALUETOTEXT",
|
|
21183
|
-
|
|
21655
|
+
C36,
|
|
21184
21656
|
"VALUETOTEXT(value, [format])",
|
|
21185
21657
|
"Text for any value.",
|
|
21186
21658
|
1,
|
|
@@ -21189,7 +21661,7 @@ var TEXT_EXTRA_FUNCTIONS = [
|
|
|
21189
21661
|
),
|
|
21190
21662
|
spec(
|
|
21191
21663
|
"ARRAYTOTEXT",
|
|
21192
|
-
|
|
21664
|
+
C36,
|
|
21193
21665
|
"ARRAYTOTEXT(array, [format])",
|
|
21194
21666
|
"Text for an array.",
|
|
21195
21667
|
1,
|
|
@@ -21954,6 +22426,8 @@ var EngineHost = class {
|
|
|
21954
22426
|
inProgress = /* @__PURE__ */ new Set();
|
|
21955
22427
|
cycles = /* @__PURE__ */ new Set();
|
|
21956
22428
|
dynamicCycleHits = /* @__PURE__ */ new Set();
|
|
22429
|
+
/** Set while a circular group is iterated: reads of a formula in progress see its stored value. */
|
|
22430
|
+
iterating = false;
|
|
21957
22431
|
pending;
|
|
21958
22432
|
columnIndex;
|
|
21959
22433
|
reverseIndex;
|
|
@@ -21993,6 +22467,7 @@ var EngineHost = class {
|
|
|
21993
22467
|
const node = this.nodes.get(sheet)?.get(cellKey(row2, col));
|
|
21994
22468
|
if (!node) return;
|
|
21995
22469
|
if (this.inProgress.has(node)) {
|
|
22470
|
+
if (this.iterating) return;
|
|
21996
22471
|
this.dynamicCycleHits.add(node);
|
|
21997
22472
|
this.dynamicCycleHit = true;
|
|
21998
22473
|
this.cycleReads++;
|
|
@@ -22311,6 +22786,10 @@ function storeResult(sheet, node, cell, result2, claims) {
|
|
|
22311
22786
|
|
|
22312
22787
|
// src/xlsx/formula/engine-core.ts
|
|
22313
22788
|
var MAX_ROUNDS = 8;
|
|
22789
|
+
function valueChange(before, after) {
|
|
22790
|
+
if (typeof before === "number" && typeof after === "number") return Math.abs(after - before);
|
|
22791
|
+
return before === after ? 0 : Number.POSITIVE_INFINITY;
|
|
22792
|
+
}
|
|
22314
22793
|
var EngineCore = class extends EngineHost {
|
|
22315
22794
|
releaseAllSpills() {
|
|
22316
22795
|
for (const sheet of this.workbook.sheets) {
|
|
@@ -22396,7 +22875,9 @@ var EngineCore = class extends EngineHost {
|
|
|
22396
22875
|
for (const component of order.components) {
|
|
22397
22876
|
const first4 = component.nodes[0];
|
|
22398
22877
|
if (component.cyclic) {
|
|
22399
|
-
|
|
22878
|
+
const iterate = this.workbook.iterate;
|
|
22879
|
+
if (iterate) this.iterateGroup(component.nodes, iterate);
|
|
22880
|
+
else for (const node of component.nodes) this.markCycle(node);
|
|
22400
22881
|
} else if (this.pending.has(first4)) {
|
|
22401
22882
|
this.computeFrom(first4);
|
|
22402
22883
|
}
|
|
@@ -22438,6 +22919,30 @@ var EngineCore = class extends EngineHost {
|
|
|
22438
22919
|
}
|
|
22439
22920
|
}
|
|
22440
22921
|
}
|
|
22922
|
+
/**
|
|
22923
|
+
* Iterative calculation of a circular group (`calcPr iterate`): every member is recomputed in
|
|
22924
|
+
* turn, reading the others' values from the previous step, until the largest change is within
|
|
22925
|
+
* `delta` or `count` passes have run. The group starts from the values the cells hold.
|
|
22926
|
+
*/
|
|
22927
|
+
iterateGroup(nodes, limits) {
|
|
22928
|
+
for (const node of nodes) this.pending?.delete(node);
|
|
22929
|
+
const cellOf2 = (node) => this.workbook.sheets[node.sheet]?.rows.get(node.row)?.get(node.col);
|
|
22930
|
+
this.iterating = true;
|
|
22931
|
+
try {
|
|
22932
|
+
for (let pass = 0; pass < limits.count; pass++) {
|
|
22933
|
+
let change = 0;
|
|
22934
|
+
for (const node of nodes) {
|
|
22935
|
+
const before = cellOf2(node)?.value ?? null;
|
|
22936
|
+
this.compute(node);
|
|
22937
|
+
const after = cellOf2(node)?.value ?? null;
|
|
22938
|
+
change = Math.max(change, valueChange(before, after));
|
|
22939
|
+
}
|
|
22940
|
+
if (change <= limits.delta) break;
|
|
22941
|
+
}
|
|
22942
|
+
} finally {
|
|
22943
|
+
this.iterating = false;
|
|
22944
|
+
}
|
|
22945
|
+
}
|
|
22441
22946
|
markCycle(node) {
|
|
22442
22947
|
this.pending?.delete(node);
|
|
22443
22948
|
this.cycles.add(node);
|
|
@@ -22928,16 +23433,16 @@ function shiftIndexClamped(index2, shift2) {
|
|
|
22928
23433
|
}
|
|
22929
23434
|
function shiftRange(range, shift2) {
|
|
22930
23435
|
if (shift2.axis === "row") {
|
|
22931
|
-
const
|
|
22932
|
-
return
|
|
22933
|
-
start: { row:
|
|
22934
|
-
end: { row:
|
|
23436
|
+
const span4 = shiftSpan(range.start.row, range.end.row, shift2);
|
|
23437
|
+
return span4 && {
|
|
23438
|
+
start: { row: span4.start, col: range.start.col },
|
|
23439
|
+
end: { row: span4.end, col: range.end.col }
|
|
22935
23440
|
};
|
|
22936
23441
|
}
|
|
22937
|
-
const
|
|
22938
|
-
return
|
|
22939
|
-
start: { row: range.start.row, col:
|
|
22940
|
-
end: { row: range.end.row, col:
|
|
23442
|
+
const span3 = shiftSpan(range.start.col, range.end.col, shift2);
|
|
23443
|
+
return span3 && {
|
|
23444
|
+
start: { row: range.start.row, col: span3.start },
|
|
23445
|
+
end: { row: range.end.row, col: span3.end }
|
|
22941
23446
|
};
|
|
22942
23447
|
}
|
|
22943
23448
|
function shiftRangeInBand(range, shift2, lo, hi) {
|
|
@@ -23749,7 +24254,9 @@ function workbookXml(workbook, sheets, activeTab, sourceXml) {
|
|
|
23749
24254
|
).join("")}</definedNames>`;
|
|
23750
24255
|
const calc = kept.get("calcPr");
|
|
23751
24256
|
const mode = workbook.calcMode === "manual" ? ' calcMode="manual"' : "";
|
|
23752
|
-
|
|
24257
|
+
const iterate = workbook.iterate ? ` iterate="1" iterateCount="${workbook.iterate.count}" iterateDelta="${workbook.iterate.delta}"` : "";
|
|
24258
|
+
const owned = ["fullCalcOnLoad", "calcId", "calcMode", "iterate", "iterateCount", "iterateDelta"];
|
|
24259
|
+
out += `<calcPr${copyAttrs(calc, owned)} calcId="191029"${mode}${iterate} fullCalcOnLoad="1"/>`;
|
|
23753
24260
|
out += raw(KEPT_TAIL);
|
|
23754
24261
|
return `${out}</workbook>`;
|
|
23755
24262
|
}
|
|
@@ -25968,8 +26475,8 @@ function shiftAxisFormats(sheet, shift2) {
|
|
|
25968
26475
|
}
|
|
25969
26476
|
sheet.columns = normalizeColumns(
|
|
25970
26477
|
sheet.columns.flatMap((info) => {
|
|
25971
|
-
const
|
|
25972
|
-
return
|
|
26478
|
+
const span3 = shiftSpan(info.min, info.max, shift2);
|
|
26479
|
+
return span3 ? [{ ...info, min: span3.start, max: span3.end }] : [];
|
|
25973
26480
|
})
|
|
25974
26481
|
);
|
|
25975
26482
|
}
|
|
@@ -26146,11 +26653,11 @@ function toHtml(cells3, theme2) {
|
|
|
26146
26653
|
if (covered.has(`${r},${c2}`)) continue;
|
|
26147
26654
|
const cell = cells3.data[r]?.[c2] ?? null;
|
|
26148
26655
|
const attrs2 = [];
|
|
26149
|
-
const
|
|
26150
|
-
if (
|
|
26151
|
-
attrs2.push(`rowspan="${
|
|
26152
|
-
if (
|
|
26153
|
-
attrs2.push(`colspan="${
|
|
26656
|
+
const span3 = spans2.get(`${r},${c2}`);
|
|
26657
|
+
if (span3 && span3.end.row > span3.start.row)
|
|
26658
|
+
attrs2.push(`rowspan="${span3.end.row - span3.start.row + 1}"`);
|
|
26659
|
+
if (span3 && span3.end.col > span3.start.col)
|
|
26660
|
+
attrs2.push(`colspan="${span3.end.col - span3.start.col + 1}"`);
|
|
26154
26661
|
if (cell && typeof cell.value === "number") attrs2.push(`x:num="${cell.value}"`);
|
|
26155
26662
|
const css = cssFor(cell?.style, theme2);
|
|
26156
26663
|
if (css) attrs2.push(`style="${escapeHtml(css)}"`);
|
|
@@ -28586,7 +29093,7 @@ var MAX_OUTLINE_LEVEL = 7;
|
|
|
28586
29093
|
function nextLevel(level, delta) {
|
|
28587
29094
|
return Math.max(0, Math.min(MAX_OUTLINE_LEVEL, (level ?? 0) + delta));
|
|
28588
29095
|
}
|
|
28589
|
-
function
|
|
29096
|
+
function span2(from, to) {
|
|
28590
29097
|
const lo = Math.max(0, Math.min(from, to));
|
|
28591
29098
|
const hi = Math.max(from, to);
|
|
28592
29099
|
return Array.from({ length: hi - lo + 1 }, (_v, i) => lo + i);
|
|
@@ -28598,7 +29105,7 @@ function outlineRows(ctx, s, from, to, delta) {
|
|
|
28598
29105
|
"structure",
|
|
28599
29106
|
[{ kind: "sheet", sheet: s }],
|
|
28600
29107
|
() => {
|
|
28601
|
-
for (const row2 of
|
|
29108
|
+
for (const row2 of span2(from, to)) {
|
|
28602
29109
|
const info = { ...sheet.rowInfo.get(row2) };
|
|
28603
29110
|
const level = nextLevel(info.outlineLevel, delta);
|
|
28604
29111
|
if (level) info.outlineLevel = level;
|
|
@@ -28619,7 +29126,7 @@ function outlineColumns(ctx, s, from, to, delta) {
|
|
|
28619
29126
|
delta > 0 ? "Group columns" : "Ungroup columns",
|
|
28620
29127
|
"structure",
|
|
28621
29128
|
[{ kind: "sheet", sheet: s }],
|
|
28622
|
-
() => editColumns(sheet,
|
|
29129
|
+
() => editColumns(sheet, span2(from, to), (info) => {
|
|
28623
29130
|
const level = nextLevel(info.outlineLevel, delta);
|
|
28624
29131
|
if (level) info.outlineLevel = level;
|
|
28625
29132
|
else {
|
|
@@ -30931,10 +31438,10 @@ function inspectZip(bytes, limits, check3) {
|
|
|
30931
31438
|
if (offset2 !== end) fail2("INVALID_ZIP", "Central directory length or count mismatch");
|
|
30932
31439
|
spans2.sort((a, b) => a.start - b.start);
|
|
30933
31440
|
let previousEnd = 0;
|
|
30934
|
-
for (const
|
|
30935
|
-
if (
|
|
31441
|
+
for (const span3 of spans2) {
|
|
31442
|
+
if (span3.start !== previousEnd)
|
|
30936
31443
|
fail2("ZIP_MISMATCH", "Overlapping, prefixed, or unindexed ZIP records");
|
|
30937
|
-
previousEnd =
|
|
31444
|
+
previousEnd = span3.end;
|
|
30938
31445
|
}
|
|
30939
31446
|
if (previousEnd !== centralStart) fail2("ZIP_MISMATCH", "Unindexed ZIP data");
|
|
30940
31447
|
return entries;
|
|
@@ -33906,17 +34413,17 @@ function flattenNurbs(controls2, sourceKnots, degree, consume, consumeWork) {
|
|
|
33906
34413
|
while (multiplicity < degree) {
|
|
33907
34414
|
charge(points.length + knots.length + degree * 4);
|
|
33908
34415
|
if (points.length >= MAX_REFINED_CONTROLS) throw failure2;
|
|
33909
|
-
let
|
|
33910
|
-
while (
|
|
34416
|
+
let span3 = degree;
|
|
34417
|
+
while (span3 < points.length - 1 && knots[span3 + 1] <= u) span3++;
|
|
33911
34418
|
const next = new Array(points.length + 1);
|
|
33912
|
-
for (let i = 0; i <=
|
|
33913
|
-
for (let i =
|
|
33914
|
-
for (let i =
|
|
34419
|
+
for (let i = 0; i <= span3 - degree; i++) next[i] = points[i];
|
|
34420
|
+
for (let i = span3 - multiplicity; i < points.length; i++) next[i + 1] = points[i];
|
|
34421
|
+
for (let i = span3 - degree + 1; i <= span3 - multiplicity; i++) {
|
|
33915
34422
|
const alpha = (u - knots[i]) / (knots[i + degree] - knots[i]);
|
|
33916
34423
|
if (!Number.isFinite(alpha) || alpha < 0 || alpha > 1) throw failure2;
|
|
33917
34424
|
next[i] = blend(points[i - 1], points[i], alpha);
|
|
33918
34425
|
}
|
|
33919
|
-
knots = [...knots.slice(0,
|
|
34426
|
+
knots = [...knots.slice(0, span3 + 1), u, ...knots.slice(span3 + 1)];
|
|
33920
34427
|
points = next;
|
|
33921
34428
|
multiplicity++;
|
|
33922
34429
|
}
|
|
@@ -33947,9 +34454,9 @@ function flattenNurbs(controls2, sourceKnots, degree, consume, consumeWork) {
|
|
|
33947
34454
|
subdivide(left2, depth + 1);
|
|
33948
34455
|
subdivide(right2.reverse(), depth + 1);
|
|
33949
34456
|
};
|
|
33950
|
-
for (let
|
|
34457
|
+
for (let span3 = degree; span3 < points.length; span3++) {
|
|
33951
34458
|
charge(1);
|
|
33952
|
-
if (knots[
|
|
34459
|
+
if (knots[span3 + 1] > knots[span3]) subdivide(points.slice(span3 - degree, span3 + 1), 0);
|
|
33953
34460
|
}
|
|
33954
34461
|
if (output.length) {
|
|
33955
34462
|
const last = controls2.at(-1);
|
|
@@ -34291,9 +34798,9 @@ function ellipticalArc(startX, startY, x, y, midX, midY, angle, ratio) {
|
|
|
34291
34798
|
const radius = Math.hypot(ax - ux, ay - uy);
|
|
34292
34799
|
const tau = Math.PI * 2;
|
|
34293
34800
|
const start = Math.atan2(ay - uy, ax - ux), mid = Math.atan2(by - uy, bx - ux), end = Math.atan2(cy - uy, cx - ux);
|
|
34294
|
-
const
|
|
34295
|
-
const sweep = middle <=
|
|
34296
|
-
const large = (sweep ?
|
|
34801
|
+
const span3 = (end - start + tau) % tau, middle = (mid - start + tau) % tau;
|
|
34802
|
+
const sweep = middle <= span3 ? 1 : 0;
|
|
34803
|
+
const large = (sweep ? span3 : tau - span3) > Math.PI ? 1 : 0;
|
|
34297
34804
|
if (!Number.isFinite(radius) || radius > 1e9) return void 0;
|
|
34298
34805
|
return `A ${point(radius, radius / ratio)} ${clean2(angle * 180 / Math.PI)} ${large} ${sweep} ${point(x, y)}`;
|
|
34299
34806
|
}
|
|
@@ -37922,17 +38429,17 @@ async function assertGeometryPackageScope(pkg, pagePaths, commands, check3, root
|
|
|
37922
38429
|
}
|
|
37923
38430
|
|
|
37924
38431
|
// src/visio/edit.ts
|
|
37925
|
-
function
|
|
38432
|
+
function positive3(value) {
|
|
37926
38433
|
if (!Number.isSafeInteger(value) || value <= 0)
|
|
37927
38434
|
fail2("INVALID_LIMITS", "Edit limits must be positive safe integers.");
|
|
37928
38435
|
return value;
|
|
37929
38436
|
}
|
|
37930
38437
|
async function editVsdx(input, edits, options = {}) {
|
|
37931
38438
|
const limits = { ...DEFAULTS, ...options.limits };
|
|
37932
|
-
for (const value of Object.values(limits))
|
|
37933
|
-
const maxEdits =
|
|
37934
|
-
const maxText =
|
|
37935
|
-
const maxOutput =
|
|
38439
|
+
for (const value of Object.values(limits)) positive3(value);
|
|
38440
|
+
const maxEdits = positive3(options.maxEdits ?? 1e3);
|
|
38441
|
+
const maxText = positive3(options.maxTextCharacters ?? 1e6);
|
|
38442
|
+
const maxOutput = positive3(options.maxOutputBytes ?? limits.maxInputBytes);
|
|
37936
38443
|
const deadline = Date.now() + limits.maxRuntimeMs;
|
|
37937
38444
|
const check3 = () => {
|
|
37938
38445
|
if (Date.now() >= deadline) fail2("LIMIT_RUNTIME", "Visio edit deadline exceeded.");
|