Skip to content

Instantly share code, notes, and snippets.

@VlT0R

VlT0R/EX 2.EXCEL.yaml

Last active Jun 10, 2021
Embed
What would you like to do?
Create a new snippet from a blank template.
name: EX 2
description: Create a new snippet from a blank template.
host: EXCEL
api_set: {}
script:
content: |
const form = document.getElementById("run") as HTMLFormElement;
form.addEventListener("click", async (event) => {
event.preventDefault();
await Excel.run(async (context) => {
const sheet = context.workbook.worksheets.getFirst();
const colunA = sheet.getRange("A1").getExtendedRange("Down");
colunA.load(["values", "rowCount"]);
await context.sync();
const forumla = [];
for (let i = 0; i < colunA.rowCount; i++) {
const v = colunA.values[i][0];
const quadra = v * v;
const raiz = Math.sqrt(v);
forumla.push([quadra, raiz]);
}
const qer = sheet.getRange(`B1:C${colunA.rowCount}`);
qer.values = forumla;
await context.sync();
});
});
language: typescript
template:
content: "<form id=\"run\">\n\t<button>Executar</button>\n\t</div>"
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