Skip to content

Instantly share code, notes, and snippets.

@XiangGaoMSFT
Created September 3, 2018 06:42
Show Gist options
  • Save XiangGaoMSFT/c2f9f8f8c4513d0126d7153f238051b3 to your computer and use it in GitHub Desktop.
Save XiangGaoMSFT/c2f9f8f8c4513d0126d7153f238051b3 to your computer and use it in GitHub Desktop.
Shared with Script Lab
name: range.getImage()
description: ''
author: xianggaomsft
host: EXCEL
api_set: {}
script:
content: |
$("#run").click(() => tryCatch(run));
async function run() {
await Excel.run(async (context) => {
var range = context.workbook.worksheets.getActiveWorksheet().getRange("A1:B5");
var image = range.getImage();
await context.sync();
// console.log(JSON.stringify(image));
$("#base64").attr("src", "data:image/png;base64," + image.value);
//console.log(image.value);
});
}
/** Default helper for invoking an action and handling errors. */
async function tryCatch(callback) {
try {
await callback();
}
catch (error) {
OfficeHelpers.UI.notify(error);
OfficeHelpers.Utilities.log(error);
}
}
language: typescript
template:
content: |
<button id="run" class="ms-Button">
<span class="ms-Button-label">Run</span>
</button>
<hr>
<div>
<img id="base64"/>
</div>
language: html
style:
content: |
/* Your style goes here */
language: css
libraries: |
https://appsforoffice.microsoft.com/lib/beta/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
@microsoft/[email protected]/dist/office.helpers.min.js
@microsoft/[email protected]/dist/office.helpers.d.ts
[email protected]
@types/jquery
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment