Skip to content

Instantly share code, notes, and snippets.

@VlT0R

VlT0R/EX 1 .yaml

Last active Jun 10, 2021
Embed
What would you like to do?
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