Skip to content

Instantly share code, notes, and snippets.

Last active August 1, 2019 06:04
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Create a new snippet from a blank template.
name: tableau 2
description: Create a new snippet from a blank template.
host: EXCEL
api_set: {}
content: |
$("#ajout").click(() => tryCatch(ajoutJSON));
async function ajoutJSON() {
await function(context) {
let feuille = context.workbook.worksheets.getActiveWorksheet();
// Ajout de la ligne de titre
let tableauJSON = feuille.tables.add("A13:D13", true); = "tableaujson";
tableauJSON.getHeaderRowRange().values = [["Formation", "Nombre", "Prix", "Total"]];
// Définition du tableau de données en JSON
var data = [
FORMATION: "Windows 10",
NOMBRE: "1",
PRIX: "950",
TOTAL: "950"
FORMATION: "Office 2019",
NOMBRE: "2",
PRIX: "1400",
TOTAL: "2800"
// Injection des données JSON à la suite de la ligne de titre
var newData = => [item.FORMATION, item.NOMBRE, item.PRIX, item.TOTAL]);
tableauJSON.rows.add(null, newData);
/** Default helper for invoking an action and handling errors. */
async function tryCatch(callback) {
try {
await callback();
} catch (error) {
// Note: In a production add-in, you'd want to notify the user through your add-in's UI.
language: typescript
content: |-
<button id="ajout" class="ms-Button">
<span class="ms-Button-label">Créer un tableau avec des données JSON</span>
language: html
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: |
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment