Can you read the formula from an Excel cell using JavaScript? RRS feed

  • Question

  • Is there a way in JavaScript to obtain the formula behind an Excel cell in Office 2013? In my application, the pure value is not sufficient.



    Friday, January 4, 2013 11:10 PM


All replies

  • Hi Wuuf,

    Thank you for posting in the MSDN Forum.

    It based on my experience that App for Office cannot get the formula.

    For more information, you can refer to CoercionType enumeration .

    Hope it helps.

    Best regards,

    Quist Zhang [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, January 7, 2013 1:54 PM
  • The dev team has been real slack on this. But there is a work around using only Javascript and worker cells.

    As Jeeped mentioned, Excel has native ISFORMULA and FORMULATEXT functions. You can create worker cells that will display the formula and simply return the data.

    //Bind Cells
    Office.context.document.bindings.addFromNamedItemAsync("A1:XFD1048576", "matrix", { id: 'objSelect'},function(e){
    //Set Worker Cell'bindings#workerCell').setDataAsync([['=FORMULATEXT('+Cell+')']],
        {startRow: 0, startColumn:99},function (asyncResult){
    //Get Function'bindings#objCell').getDataAsync({ coercionType: 'matrix', startRow: 0, startCol: 99, rowCount: 1, colCount: 1 }, 
            function (result) {

    Saturday, December 20, 2014 5:16 AM