Created
April 24, 2024 15:19
-
-
Save s-ratashnyuk/c3c124f2bb01d8b074a0c506d6d85bb6 to your computer and use it in GitHub Desktop.
Register functions
This file contains 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: Basic custom function | |
description: Calculates the volume of a sphere. | |
host: EXCEL | |
api_set: {} | |
script: | |
content: | | |
/** | |
* Return fixed spill range | |
* @customfunction MKSPILL | |
*/ | |
async function spillFixed(): Promise<number[][]> { | |
return new Promise((res) => { | |
setTimeout(() => { | |
res([1, 3, 4, 5, 6, 7, 3, 4, 5, 6, 3, 4, 5, 33].map((x) => [x])); | |
}, Math.ceil(Math.random() * 100)); | |
}); | |
} | |
/** | |
* Delay and return the given delay argument | |
* @customfunction MKDELAY | |
* @param delayTime Time in ms to delay | |
* @returns number | |
*/ | |
async function makeDelay(delayTime: number): Promise<number> { | |
return new Promise((res) => { | |
setTimeout(() => { | |
res(delayTime); | |
}, delayTime); | |
}); | |
} | |
/** | |
* Increments a value of the cell. | |
* @customfunction INCRE | |
* @param {number[][]} [incrementBy] Amount to increment | |
*/ | |
function incrementBy(incrementBy: number[][]): number { | |
const rawVal = localStorage.getItem("sr-1"); | |
const parsedVal = parseInt(rawVal); | |
const val = isNaN(parsedVal) ? 0 : parsedVal; | |
const nextVal = val + incrementBy[0][0]; | |
localStorage.setItem("sr-1", nextVal.toString()); | |
return nextVal; | |
} | |
language: typescript | |
libraries: | | |
https://appsforoffice.microsoft.com/lib/1/hosted/office.js | |
@types/office-js | |
core-js@2.4.1/client/core.min.js |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment