Created
May 12, 2021 01:26
-
-
Save ErickPetru/9267d94c017223a910679541d84cbca9 to your computer and use it in GitHub Desktop.
Faz chamadas básicas à API Excel para mudar a cor de fundo de células selecionadas ou limpar a formatação.
This file contains hidden or 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: Exemplo Básico | |
description: >- | |
Faz chamadas básicas à API Excel para mudar a cor de fundo de células | |
selecionadas ou limpar a formatação. | |
host: EXCEL | |
api_set: {} | |
script: | |
content: | | |
const run = document.getElementById("run"); | |
run.addEventListener("click", () => { | |
Excel.run(async (context) => { | |
const range = context.workbook.getSelectedRange(); | |
range.format.fill.color = "yellow"; | |
range.load("address"); | |
await context.sync(); | |
console.log(`Foi destacado o intervalo de células "${range.address}".`); | |
}); | |
}); | |
const clean = document.getElementById("clean"); | |
clean.addEventListener("click", () => { | |
Excel.run(async (context) => { | |
const sheet = context.workbook.worksheets.getActiveWorksheet(); | |
sheet.getUsedRange().format.fill.clear(); | |
await context.sync(); | |
console.log("Os destaques foram limpos na planilha ativa."); | |
}); | |
}); | |
language: typescript | |
template: | |
content: "<section class=\"ms-font-m\">\n\t<p class=\"ms-font-m\">Este exemplo básico mostra como fazer chamadas à API Excel.</p>\n</section>\n\n<section class=\"samples ms-font-m\">\n\t<h3>Experimente!</h3>\n\t<p class=\"ms-font-m\">Selecione algumas células em uma planilha, então utilize o botão abaixo.</p>\n\t<button id=\"run\" class=\"ms-Button\">\n <span class=\"ms-Button-label\">Destacar células selecionadas</span>\n </button>\n</section>\n\n<section class=\"samples ms-font-m\">\n\t<h3>Quer começar de novo?</h3>\n\t<p class=\"ms-font-m\">Utilize este outro botão para retirar os destaques.</p>\n\t<button id=\"clean\" class=\"ms-Button\">\n <span class=\"ms-Button-label\">Limpar destaques</span>\n </button>\n</section>" | |
language: html | |
style: | |
content: | | |
section.samples { | |
margin-top: 20px; | |
} | |
section.samples .ms-Button, section.setup .ms-Button { | |
display: block; | |
margin-bottom: 5px; | |
margin-left: 20px; | |
min-width: 80px; | |
} | |
language: css | |
libraries: | | |
https://appsforoffice.microsoft.com/lib/1/hosted/office.js | |
@types/office-js | |
[email protected]/dist/css/fabric.min.css | |
[email protected]/dist/css/fabric.components.min.css | |
[email protected]/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