Last active
December 8, 2020 06:39
-
-
Save ci010/b8fa6480ae3a492803c82cf3f4bd3ee2 to your computer and use it in GitHub Desktop.
Adjust a chart title's format.
This file contains 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: BugBash | |
description: Adjust a chart title's format. | |
host: EXCEL | |
api_set: {} | |
script: | |
content: | | |
function getDir() { | |
const dir = $("#direction").val(); | |
switch (dir) { | |
case "up": | |
return Excel.KeyboardDirection.up; | |
case "right": | |
return Excel.KeyboardDirection.right; | |
case "left": | |
return Excel.KeyboardDirection.left; | |
case "down": | |
return Excel.KeyboardDirection.down; | |
} | |
throw new Error("FAIL TO GET DIR"); | |
} | |
$("#getExtendedRange").click(() => { | |
Excel.run(async (ctx) => { | |
const range = ctx.workbook.getSelectedRange(); | |
const cell = ctx.workbook.getActiveCell(); | |
const dir = getDir(); | |
const activeCell = $("#activeCell").val() as string; | |
const result = range.getExtendedRange(dir, activeCell ? activeCell : cell); | |
result.select(); | |
}).catch(console.error); | |
}); | |
$("#getRangeEdge").click(() => { | |
Excel.run(async (ctx) => { | |
const range = ctx.workbook.getSelectedRange(); | |
const dir = getDir(); | |
const activeCell = $("#activeCell").val() as string; | |
const result = range.getRangeEdge(dir, activeCell ? activeCell : undefined); | |
result.select(); | |
}).catch(console.error); | |
}); | |
$("#resize").click(() => { | |
Excel.run(async (ctx) => { | |
const range = ctx.workbook.getSelectedRange(); | |
const tableName = $("#table").val() as string; | |
const table = ctx.workbook.tables.getItem(tableName); | |
table.resize(range); | |
}).catch(console.error); | |
}); | |
language: typescript | |
template: | |
content: "<section class=\"samples ms-font-m\">\n\t<span>Direction</span>\n\t<select name=\"direction\" id=\"direction\">\n <option value=\"up\">Up</option>\n <option value=\"left\">Left</option>\n <option value=\"right\">Right</option>\n <option value=\"down\">Down</option>\n </select>\n\t<span>Active Cell</span>\n\t<input type=\"text\" id=\"activeCell\">\n\t<button class=\"ms-button\" id=\"getRangeEdge\">\n getRangeEdge\n </button>\n\t<button class=\"ms-button\" id=\"getExtendedRange\">\n getExtendedRange\n </button>\n</section>\n\n<section class=\"samples ms-font-m\">\n\t<span>Resize table named</span>\n\t<input type=\"text\" id=\"table\">\n\tto current selected range\n\t<button id=\"resize\"> Resize </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://unpkg.com/@microsoft/office-js@1.1.44-custom.38/dist/office.debug.js | |
https://unpkg.com/@microsoft/office-js@1.1.44-custom.38/dist/office-with-first-party.d.ts | |
office-ui-fabric-js@1.4.0/dist/css/fabric.min.css | |
office-ui-fabric-js@1.4.0/dist/css/fabric.components.min.css | |
core-js@2.4.1/client/core.min.js | |
@types/core-js | |
@microsoft/office-js-helpers@0.7.4/dist/office.helpers.min.js | |
@microsoft/office-js-helpers@0.7.4/dist/office.helpers.d.ts | |
jquery@3.1.1 | |
@types/jquery@3.3.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment