From dcccc219b4ffd927c0f12cec0994576f29322d91 Mon Sep 17 00:00:00 2001 From: Eeshaan Sawant Date: Thu, 27 Jun 2024 16:22:16 +0530 Subject: [PATCH] Added scripts for QUARTILE method --- ApiWorksheetFunction_QUARTILE.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 ApiWorksheetFunction_QUARTILE.js diff --git a/ApiWorksheetFunction_QUARTILE.js b/ApiWorksheetFunction_QUARTILE.js new file mode 100644 index 0000000..7bc643c --- /dev/null +++ b/ApiWorksheetFunction_QUARTILE.js @@ -0,0 +1,21 @@ +builder.CreateFile("xlsx"); +const oWorksheet = Api.GetActiveSheet(); + +var valueArr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]; +var quart = 3; //eg: third quartile (75th percentile) + +// Place the numbers in cells +for (var i = 0; i < valueArr1.length; i++) { + oWorksheet.GetRange("A" + (i + 1)).SetValue(valueArr1[i]); +} + +//method params +var array = oWorksheet.GetRange("A1:A12"); + +var oFunction = Api.GetWorksheetFunction(); +var ans = oFunction.QUARTILE(array, quart); + +oWorksheet.GetRange("C1").SetValue(ans); + +builder.SaveFile("xlsx", "QUARTILE.xlsx"); +builder.CloseFile();