Created
December 1, 2020 12:20
-
-
Save ci010/b6e7fb18dd52232ed3f6f55b11230c8a 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 dir = getDir(); | |
const activeCell = $("#activeCell").val(); | |
const result = range.getExtendedRange(dir, activeCell ? activeCell : undefined); | |
result.select(); | |
}).catch(console.error); | |
}); | |
$("#getRangeEdge").click(() => { | |
Excel.run(async (ctx) => { | |
const range = ctx.workbook.getSelectedRange(); | |
const dir = getDir(); | |
const activeCell = $("#activeCell").val(); | |
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(); | |
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 <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://appsforoffice.microsoft.com/lib/1/hosted/office.js | |
@types/office-js | |
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