Skip to content

Instantly share code, notes, and snippets.

@maninweb
Created March 26, 2019 10:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maninweb/8754249beff8460abeacd6a323fddd2e to your computer and use it in GitHub Desktop.
Save maninweb/8754249beff8460abeacd6a323fddd2e to your computer and use it in GitHub Desktop.
Maninweb-Addin
name: Maninweb-Addin
description: Maninweb-Addin
host: EXCEL
api_set: {}
script:
content: |
Office.initialize = function(reason) {
Excel.Script.CustomFunctions = {};
Excel.Script.CustomFunctions["ML"] = {};
function GetAnswer() {
return 42;
}
function GetAnswerHelp() {
return Office.context.displayLanguage.toLowerCase() == "de-de"
? "https://de.excel-translator.de"
: "https://en.excel-translator.de";
}
function GetLanguageDescription() {
return Office.context.displayLanguage.toLowerCase() == "de-de" ? "Deutsch" : "English";
}
function GetLanguageHelp() {
return Office.context.displayLanguage.toLowerCase() == "de-de"
? "https://de.excel-translator.de"
: "https://en.excel-translator.de";
}
function GetLanguageFunction() {
return Office.context.displayLanguage.toLowerCase() == "de-de" ? "SPRACHE" : "LANGUAGE";
}
function GetLanguageValue() {
return Office.context.displayLanguage.toLowerCase();
}
Excel.Script.CustomFunctions["ML"]["SYSLANG"] = {
call: GetLanguageValue,
description: GetLanguageDescription(),
helpUrl: GetLanguageHelp(),
result: {
resultType: Excel.CustomFunctionValueType.string,
resultDimensionality: Excel.CustomFunctionDimensionality.scalar
},
parameters: [],
options: { batch: false, stream: false }
};
Excel.Script.CustomFunctions["ML"][GetLanguageFunction()] = {
call: GetLanguageValue,
description: GetLanguageDescription(),
helpUrl: GetLanguageHelp(),
result: {
resultType: Excel.CustomFunctionValueType.string,
resultDimensionality: Excel.CustomFunctionDimensionality.scalar
},
parameters: [],
options: { batch: false, stream: false }
};
switch (Office.context.displayLanguage.toLowerCase()) {
case "de-de":
Excel.Script.CustomFunctions["ML"]["ANTWORTAUFALLES"] = {
call: GetAnswer,
description: "Die Antwort auf alles.",
helpUrl: GetAnswerHelp(),
result: {
resultType: Excel.CustomFunctionValueType.number,
resultDimensionality: Excel.CustomFunctionDimensionality.scalar
},
parameters: [],
options: { batch: false, stream: false }
};
break;
default:
Excel.Script.CustomFunctions["ML"]["ANSWERTOANYTHING"] = {
call: GetAnswer,
description: "The answer to anything.",
helpUrl: GetAnswerHelp(),
result: {
resultType: Excel.CustomFunctionValueType.number,
resultDimensionality: Excel.CustomFunctionDimensionality.scalar
},
parameters: [],
options: { batch: false, stream: false }
};
}
Excel.run(function(context) {
context.workbook.customFunctions.addAll();
return context.sync().then(function() {});
}).catch(function(error) {});
};
language: typescript
template:
content: |
<button id="run" class="ms-Button">
<span class="ms-Button-label">Run</span>
</button>
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