Download presentation
Presentation is loading. Please wait.
1
Custom Functions in Excel
5/13/2018 2:45 PM Custom Functions in Excel Michael Saunders Program Manager © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
2
Demo The Chocolate Factory 5/13/2018 2:45 PM
© Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
4
Introducing custom functions
5/13/2018 2:45 PM Introducing custom functions run across all Excel platforms run JavaScript run fast look and feel like native Excel functions make web service calls (if desired) shipped by developers as part of an add-in run offline if they don’t depend on the web run even when the workbook is unattended Developer Preview coming soon: © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
5
Non-Developer Builders
Who is the customer? Developers Non-Developer Builders 1. Develop add-in with custom functions 1. Author custom function in Excel 2. Publish to the store or enterprise 2. Enable for you or your team End-Users 3. Get, use, and manage in Excel 4. Share with others
6
Microsoft Build 2017 5/13/2018 2:45 PM Office Add-ins Extend Office applications across platforms using web technologies. Distribute via store or your company catalog via centralized deployment. (with Office.js) HTML manifest.xml Your own web app Office Add-in © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
7
Office Add-ins: Building Blocks
Microsoft Build 2017 5/13/2018 2:45 PM Office Add-ins: Building Blocks Extension Points Add-in commands Custom functions x Pane title Containers Taskpane Dialog Content Dialog Title WebView Web Views (HTML/CSS/JavaScript) Use Office.js to interact with office © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
8
= Package and structure for add-ins + + Add-in manifest Packaged XML
5/13/2018 2:45 PM Package and structure for add-ins = Office add-in + + Add-in manifest Packaged XML Web page Dev-Hosted HTML JavaScript CSS Function code Packaged* JavaScript © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
9
Function code function addTo42(num) { return num + 42; }
5/13/2018 2:45 PM Function code function addTo42(num) { return num + 42; } © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
10
Function code (definition)
5/13/2018 2:45 PM Function code (definition) Excel.Script.CustomFunctions[“CONTOSO"] = {}; Excel.Script.CustomFunctions[“CONTOSO"]["ADDTO42"] = { call: addTo42, description: "Returns the sum of a number and 42", helpUrl: " result: { resultType: Excel.CustomFunctionValueType.number, resultDimensionality: Excel.CustomFunctionDimensionality.scalar, }, parameters: [{ name: "num", description: "The number be added", valueType: Excel.CustomFunctionValueType.number, valueDimensionality: Excel.CustomFunctionDimensionality.scalar, }], options: { batch: false, stream: false } }; © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
11
Function code (registration)
5/13/2018 2:45 PM Function code (registration) Excel.run(function (context) { context.workbook.customFunctions.add(“CONTOSO.ADDTO42"); return context.sync(); }); © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
12
Manifest code <Hosts> <Host xsi:type="Workbook">
5/13/2018 2:45 PM Manifest code <Hosts> <Host xsi:type="Workbook"> <AllFormFactors> <ExtensionPoint xsi:type="CustomFunctions"> <Script> <SourceLocation resid="functionsjs" /> </Script> <Page> <SourceLocation resid="functionshtml"/> </Page> </ExtensionPoint> </AllFormFactors> </Host> </Hosts> <Resources> <bt:Urls> <bt:Url id="functionsjs" DefaultValue=" />* <bt:Url id="functionshtml" DefaultValue=" /> </bt:Urls> </Resources> © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
13
5/13/2018 2:45 PM Features © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
14
Asynchronous functions
5/13/2018 2:45 PM Asynchronous functions Excel Developer JavaScript Developer Server function invocation return Promise HTTP request (if needed) HTTP response resolve Promise © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
15
Asynchronous function
5/13/2018 2:45 PM Asynchronous function function getTemperature(thermometerID){ return Excel.Promise(function(setResult, setError){ getTempFromServer(thermometerID, function(data){ setResult(data.temperature); }); } © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
16
Demo Kevin Naidu Principal Architect – Sage
5/13/2018 2:45 PM Demo Kevin Naidu Principal Architect – Sage Financial Reporting with Custom Functions © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
17
Streamed functions Excel Developer JavaScript Developer Server
5/13/2018 2:45 PM Streamed functions Excel Developer JavaScript Developer Server function invocation streaming (eg. WebSocket sendmessage) streaming (eg. Websocket onmessage) set result streaming (eg. Websocket onmessage) set result streaming (eg. Websocket onmessage) set result © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
18
5/13/2018 2:45 PM Streamed function function streamTemperature(thermometerID, interval, setResult){ function getNextTemperature(){ getTempFromServer(thermometerID, function(data){ setResult(data.temperature); }); setTimeout(getNextTemperature, interval); } getNextTemperature(); options: { batch: false, stream: true } © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
19
Saving State var savedTemperatures{};
5/13/2018 2:45 PM Saving State var savedTemperatures{}; function streamTemperature(thermometerID, interval, setResult){ if(!savedTemperatures[thermometerID]) refreshTemperature(thermometerID); function getNextTemperature(){ setResult(savedTemperatures[thermometerID]); // sends the saved value to Excel. setTimeout(getNextTemperature, interval); // wait before updating Excel again } getNextTemperature(); function refreshTemperature(thermometerID){ sendWebRequestExample(thermometerID, function(data){ savedTemperatures[thermometerID] = data.temperature; }); setTimeout(function(){ refreshTemperature(thermometerID); }, 1000); // wait 1 second before updating the saved temperature for thermometerID © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
20
Working with ranges function secondHighestTemp(temperatures){
5/13/2018 2:45 PM Working with ranges function secondHighestTemp(temperatures){ var highest = -273, secondHighest = -273; for(var i = 0; i < temperatures.length;i++){ for(var j = 0; j < temperatures[i].length;j++){ if(temperatures[i][j] >= highest){ secondHighest = highest; highest = temperatures[i][j]; } else if(temperatures[i][j] >= secondHighest){ secondHighest = temperatures[i][j]; return secondHighest; parameter[0].valueDimensionality = Excel.CustomFunctionDimensionality.matrix; © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
21
Output ranges function trackTemperature(thermometerID, setResult){
5/13/2018 2:45 PM Output ranges function trackTemperature(thermometerID, setResult){ var output; for(var i = 0; i < 50; i++) output[i] = 0; function recordNextTemperature(){ getTempFromServer(thermometerID, function(data){ output.push([data.temperature]); output.shift(); setResult(output); }); setTimeout(recordNextTemperature,500); } recordNextTemperature(); result.valueDimensionality = Excel.CustomFunctionDimensionality.matrix; © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
22
Without batching: Excel Office JavaScript API Add-in/custom function
User enters function with parameter a Calculates function with parameter a User enters function with parameter b User enters function with parameter c Result x displays Calculates function with parameter b Result y displays Calculates function with parameter c Result z displays
23
With batching: Excel Office JavaScript API Add-in/custom function
Batching controller User enters function with parameter User enters function with parameter Translate to JavaScript Array User enters function with parameter Extracts parameters and optimizes calculation for all parameters Batch result dispatcher Result x displays Result y displays Result z displays
24
Batching* function getTemperature(thermometerIDs){
5/13/2018 2:45 PM Batching* function getTemperature(thermometerIDs){ return Excel.Promise(function(setResult, setError){ getTempsFromServer(thermometerIDs, function(data){ setResult(data.temperatures); }); } options: { batch: true, stream: false } © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
25
Sneak peek: Azure ML Functions
5/13/2018 2:45 PM Sneak peek: Azure ML Functions © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
26
5/13/2018 2:45 PM Roadmap © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
27
October: Developer Preview
5/13/2018 2:45 PM October: Developer Preview Go to aka.ms/customfunctions to sign up for updates Features: Cell references, async functions, streaming, ranges Next few months Watch for updates and announcements on aka.ms/customfunctions Give us feedback Features: Other Excel platforms, batching, cancelation 2018 We’ll announce general availability Allow deployment to Store and enterprise Features: More platforms, local JavaScript runtimes, offline runtime © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
28
Please evaluate this session Your feedback is important to us!
5/13/2018 2:45 PM Please evaluate this session Your feedback is important to us! The slide will be replaced onsite through Silver Fox Productions with an updated QR code. This slide is required. Do NOT delete or alter the slide. From your PC or Tablet visit MyIgnite at From your phone download and use the Ignite Mobile App by scanning the QR code above or visiting © 2014 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.