Created
November 12, 2019 06:29
-
-
Save jiju-MS/43cf355dff718b0a94575bbd2723bfb3 to your computer and use it in GitHub Desktop.
Calculates the volume of a sphere.
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: Return Error Demo(Stock) | |
description: Calculates the volume of a sphere. | |
host: EXCEL | |
api_set: {} | |
script: | |
content: |- | |
/** | |
* Calculates the volume of a sphere. | |
* @customfunction | |
* @param {string | number} res | |
* @returns The volume of the sphere. | |
*/ | |
function InputStockInfoArray(stockcode: string): any[][] { | |
let stockInfo: any[][]; | |
stockInfo = GetStockInfo(stockcode); | |
var error = | |
{ | |
"errorcode": CustomFunctions.ErrorCode.notAvailable, | |
"errormessage": "No Data For " + stockcode | |
}; | |
stockInfo.map(item => { | |
if (item[0] == "N/A") { | |
item[0] = error; | |
} | |
}) | |
return stockInfo; | |
} | |
function GetStockInfo(stockcode: string): any[][] { | |
switch (stockcode) { | |
case "MSFT": { | |
return [[140.41], [140.95], ["0.00 x 2200"], ["0.00 x 1400"], ["139.03 - 141.41"], ["93.96 - 142.37"], [18152835], [24425081], ["1.067T"], [0.96], [27.61], [5.06], [43761], ["2.04(1.45 %)"], [43691], [156.77]]; | |
} | |
case "AMZN": { | |
return [["1777.43"], ["1796.49"], ["0.00 x 800"], ["0.00 x 800"], ["1,782.02 - 1,798.85"], ["1,307.00 - 2,035.80"], ["2713773"], ["3262000"], ["884.188B"], ["1.63"], ["74.16"], ["24.1"], ["43762"], ["N/A"], ["N/A"], ["2303.69"]]; | |
} | |
case "GOOG": { | |
return [["1243.64"], ["1250.93"], ["0.00 x 800"], ["0.00 x 800"], ["1,249.94 - 1,263.32"], ["970.11 - 1,289.27"], ["980510"], ["1387353"], ["868.653B"], ["0.94"], ["25.3"], ["49.53"], ["N/A"], ["N/A"], ["N/A"], ["1427.52"]]; | |
} | |
case "AAPL": { | |
return [["234.37"], ["235.09"], ["0.00 x 900"], ["0.00 x 1300"], ["233.52 - 236.15"], ["142.00 - 238.13"], ["17272897"], ["28207895"], ["1.063T"], ["1.1"], ["19.98"], ["11.78"], ["43768"], ["3.08 (1.31%)"], ["43686"], ["230.2"]]; | |
} | |
case "NFLX": { | |
return [["286.28"], ["304.49"], ["0.00 x 800"], ["0.00 x 800"], ["288.32 - 308.74"], ["231.23 - 385.99"], ["38462343"], ["8553887"], ["128.439B"], ["1.47"], ["93.99"], ["3.12"], ["Jan 15, 2020 - Jan 20, 2020"], ["N/A"], ["N/A"], ["362.05"]]; | |
} | |
case "UBER": { | |
return [["31.87"], ["31.8"], ["0.00 x 2900"], ["32.66 x 1000"], ["31.45 - 32.93"], ["28.31 - 47.08"], ["7040240"], ["9521595"], ["55.454B"], ["N/A"], ["N/A"], ["-3.01"], ["43773"], ["N/A"], ["N/A"], ["49.53"]]; | |
} | |
} | |
} | |
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