Skip to content

Instantly share code, notes, and snippets.

@vishwesh17
Created August 15, 2019 19:34
Show Gist options
  • Save vishwesh17/0e0abe24c806bd727ab4fb1519740be5 to your computer and use it in GitHub Desktop.
Save vishwesh17/0e0abe24c806bd727ab4fb1519740be5 to your computer and use it in GitHub Desktop.
working so far and need to play around
name: abc123
description: working so far and need to play around
host: EXCEL
api_set: {}
script:
content: |-
/**
* Calculates the volume of a sphere.
* @customfunction
* @param {number} radius
* @returns The volume of the sphere.
*/
// JSON to CSV Converter
function ConvertToCSV(objArray) {
var array = typeof objArray != "object" ? JSON.parse(objArray) : objArray;
var str = "";
for (var i = 0; i < array.length; i++) {
var line = "";
for (var index in array[i]) {
if (line != "") line += ",";
line += array[i][index];
}
str += line + "\r\n";
}
return str;
}
/**@customfunction */
function trialworking() {
var jsonObject;
console.log("inside trialworking()");
return fetch("https://api.coinmarketcap.com/v1/ticker/")
.then((response) => response.json())
.then((json) => {
// Convert Object to JSON
jsonObject = JSON.stringify(json);
console.log("json stringify... " + jsonObject);
})
.then(() => jsonObject);
}
/** @customfunction */
function working() {
var obj;
console.log("inside trial()");
return fetch("https://api.coinmarketcap.com/v1/ticker/")
.then((response) => response.json())
.then((json) => {
console.log("inide json then.." + json[0].name);
obj = json[0].name;
})
.then(() => obj);
}
/** @customfunction
async function abc() {
console.log("inside trial1()");
let obj = await fetch("https://api.coinmarketcap.com/v1/ticker/")
.then((json) => {
console.log("inside json then.." + json[0].name);
obj = json[0].name;
})
.then(() => obj);
console.log("outside fetch then..." + obj);
return obj;
}
*/
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