Simplified API

If you have recorded or created Office Scripts using the older model, rest assured that such scripts will continue to work.
You can continue to edit and run such scripts. However, all newly recorded and created scripts will use the simplified Office Scripts API.


function main

The fourth iteration was released in September 2020 and was called Office Scripts Simplified API.
This was introduced because end users were finding the Office JS API very hard to learn.

function main(workbook: ExcelScript.Workbook) { 
   const sheet = workbook.getWorksheet('Sheet1');
   if (sheet) {
      sheet.setName('BETTER');
      sheet.setPosition(0);
   }
}

async function main

The third iteration was released in January 2020 and was called Office Scripts.
At this point there was only one JavaScript API and it was still called Office JS.
This required knowledge of asynchronous programming concepts.
The API and object model are complicated even for basic tasks.

async function main(context: Excel.RequestContext) { 

}

RequestContext

The second iteration was released in March 2014 and was called Office Add-ins.
At this point there was only one JavaScript API and this was still called Office JS 1.1
This introduced a dedicated API for each of the different applications: Excel API.
This uses the RequestContext syntax.

Excel.run(function(context) { 
    var _workbook = context.workbook;
    var _sheet = _workbook.worksheets.add();

    return context.sync();
});

Apps for Office

The first iteration was released in August 2012 and was called Apps for Office.
At this point there was only one JavaScript API and this was called Office JS 1.0
This used a Shared API across all the Office 2013 applications.
All the methods were asynchronous and were suffixed with the word "Async".
This was also known as the Async Callbacks.
This was available for Excel, Word, PowerPoint and Outlook and had very limited functionality.

Office.context.document.getSelectedDataAsync(Office.CoercionType.Text, 
    function (result) {
        write('Selected data: ' + result.value);
    }
});

© 2022 Better Solutions Limited. All Rights Reserved. © 2022 Better Solutions Limited TopPrevNext