Last active
February 5, 2023 13:25
-
-
Save smozgur/dab91373d837cb29914bf2793f8c8e13 to your computer and use it in GitHub Desktop.
Generates a list of sequential numbers with transpose option
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Excel Custom Function | |
description: Generates a list of sequential numbers with transpose option | |
host: EXCEL | |
api_set: {} | |
script: | |
content: > | |
/** | |
* Excel Custom SEQUENCE function | |
* Generates a list of sequential numbers | |
* with transpose option | |
* | |
* @customfunction | |
* @params {number} rows | |
* @params {number} [columns] | |
* @params {number} [start] | |
* @params {number} [step] | |
* @params {boolean} [transpose] | |
* | |
* @return {number[][]} | |
*/ | |
function CF_SEQUENCE(rows: number, columns?: number, start?: number, step?: | |
number, transpose?: boolean) { | |
const error = new CustomFunctions.Error(CustomFunctions.ErrorCode.invalidValue); | |
if (rows < 1) { | |
return error; | |
} | |
columns = columns || 1; | |
start = start ?? 1; | |
step = step || 1; | |
const rng = []; | |
if (transpose) { | |
[rows, columns] = [columns, rows] | |
} | |
for (var i = 0; i < rows; i++) { | |
rng[i] = []; | |
for (var j = 0; j < columns; j++) { | |
rng[i][j] = start; | |
start = start + step; | |
} | |
} | |
return rng; | |
} | |
language: typescript | |
libraries: | | |
https://appsforoffice.microsoft.com/lib/1/hosted/office.js | |
@types/office-js | |
[email protected]/dist/css/fabric.min.css | |
[email protected]/dist/css/fabric.components.min.css | |
[email protected]/client/core.min.js | |
@types/core-js | |
[email protected] | |
@types/[email protected] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment