Last active
March 16, 2018 03:36
-
-
Save jipyua/deac259bb028de0ae2dd66e78bed3de5 to your computer and use it in GitHub Desktop.
Shared with Script Lab
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: ppt createDocument | |
description: '' | |
author: jipyua | |
host: POWERPOINT | |
api_set: {} | |
script: | |
content: |- | |
$('#createppt').click(function () { createPPTDocument() }); | |
function createPPTDocument() { | |
var file = document.getElementById('myFile').files[0]; | |
if (file == null) { | |
createPPT(""); | |
return; | |
} | |
var reader = new FileReader(); | |
reader.onload = function (e) { | |
var binary = ''; | |
var bytes = new Uint8Array(e.target.result); | |
var len = bytes.byteLength; | |
for (var i = 0; i < len; i++) { | |
binary += String.fromCharCode(bytes[i]); | |
} | |
var base64 = window.btoa(binary); | |
createPPT(base64); | |
} | |
reader.readAsArrayBuffer(file); | |
} | |
function createPPT(base64) { | |
Office.context.application.createDocumentAsync({ base64 }, function (asyncResult) { | |
if (asyncResult.status == Office.AsyncResultStatus.Failed) { | |
//app.showNotification(asyncResult.error.name, asyncResult.error.message); | |
console.log(asyncResult.error.name); | |
} else { | |
//app.showNotification("Success", "Success"); | |
console.log("success"); | |
} | |
}); | |
} | |
language: typescript | |
template: | |
content: "<form>\n\t<button id=\"createppt\">Create presentation</button>\n\t<p>\n\tSelect document to be inserted <br> <input id=\"myFile\" name=\"myFile\" type=\"file\">\n\n\n\n</form>" | |
language: html | |
style: | |
content: | | |
https://appsforoffice.microsoft.com/lib/beta/hosted/office.js | |
https://appsforoffice.microsoft.com/lib/beta/hosted/office.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 | |
language: css | |
libraries: |4- | |
https://appsforoffice.microsoft.com/lib/beta/hosted/office.js | |
https://appsforoffice.microsoft.com/lib/beta/hosted/office.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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment