Skip to content

Instantly share code, notes, and snippets.

@VlT0R
Last active June 10, 2021 23:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VlT0R/6d5dc192e6cf805ade72532152a05d1b to your computer and use it in GitHub Desktop.
Save VlT0R/6d5dc192e6cf805ade72532152a05d1b to your computer and use it in GitHub Desktop.
EXERCICIO 1 -10/06/2021
name: Blank snippet (3)
description: Create a new snippet from a blank template.
host: EXCEL
api_set: {}
script:
content: "const prepare = document.getElementById(\"prepare\") as HTMLButtonElement;\r\n\r\nconst calc = document.getElementById(\"calc\") as HTMLButtonElement;\r\n\r\ncalc.addEventListener(\"click\", async () => {\r\n await Excel.run(async (context) => {\r\n const sheet = context.workbook.worksheets.getActiveWorksheet();\r\n\r\n const inputRange = sheet.getRange(\"B2:B6\");\r\n const inputResult = sheet.getRange(\"A1:B1\");\r\n\r\n inputRange.load(\"values\");\r\n await context.sync();\r\n\r\n const n1 = parseFloat(inputRange.values[0][0]);\r\n const n2 = parseFloat(inputRange.values[1][0]);\r\n const n3 = parseFloat(inputRange.values[2][0]);\r\n const n4 = parseFloat(inputRange.values[3][0]);\r\n const n5 = parseFloat(inputRange.values[4][0]);\r\n\r\n \r\n\r\n\r\n let max;\r\n let min;\r\n\r\n if (n1>n2 && n1>n3 && n1>n4 && n1>n5) {\r\n max = n1;\r\n } \r\n else if (n2 > n1 && n2 > n3 && n2 > n4 && n2 > n5) {\r\n max = n2;\r\n } else if (n3 > n1 && n3 > n2 && n3 > n4 && n3 > n5) {\r\n max = n3;\r\n } else if (n4 > n1 && n4 > n2 && n4 > n3 && n4 > n5) {\r\n max = n4;\r\n } else if (n5 > n1 && n5 > n2 && n5 > n3 && n5 > n4) {\r\n max = n5;\r\n }\r\n\r\n if (n1 < n2 && n1 < n3 && n1 < n4 && n1 < n5) {\r\n min = n1;\r\n }\r\n else if (n2 < n1 && n2 < n3 && n2 < n4 && n2 < n5) {\r\n min = n2;\r\n } else if (n3 < n1 && n3 < n2 && n3 < n4 && n3 < n5) {\r\n min = n3;\r\n } else if (n4 < n1 && n4 < n2 && n4 < n3 && n4 < n5) {\r\n min = n4;\r\n } else if (n5 < n1 && n5 < n2 && n5 < n3 && n5 < n4) {\r\n min = n5;\r\n }\r\n\r\n \r\n\r\n\r\n \r\n\r\n const outputRange = sheet.getRange(\"A1\");\r\n outputRange.values = [[max]];\r\n\r\n const outputRange2 = sheet.getRange(\"B1\");\r\n outputRange2.values = [[min]];\r\n await context.sync();\r\n });\r\n});\r\n"
language: typescript
template:
content: "<p> preencha as celulas B2,B3 e B4 e veja o resultado em B6</p>\r\n\r\n<form id=\"form\">\r\n\t<button id=\"calc\">Submeter</button>\r\n</form>\r\n\r\n\r\n"
language: html
style:
content: ''
language: css
libraries: |+
https://appsforoffice.microsoft.com/lib/1/hosted/office.js
@types/office-js
core-js@2.4.1/client/core.min.js
@types/core-js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment