none
Has Microsoft abandoned the Javascript API for Excel Online (Ewa Namespace)?

    질문

  • The embed code generated by OneDrive for personal use has recently changed.  In the past the Javascript made reference to a library, and included code that used functions defined in that library to embed an Excel workbook (web part) in a web page (<div> element).  Now the code created by OneDrive uses a single URL with parameters to embed the web part as a <div> element.  Web apps that rely on the Javascrip API seem to have stopped working.  Has Microsoft abandoned this technology? Is there new documentation available I can use to help migrate these solutions to whatever Micorsoft's new platform is for embedding workbooks into public web pages?

    Thanks in advance!

    MiltonCR


    • 편집됨 MiltonCR 2018년 6월 14일 목요일 오전 1:05
    2018년 6월 14일 목요일 오전 1:04

답변

  • H-Logic,

    Thanks for your help.  I noticed both your code and the embed code define the <body> document elements before the embed script:

    <body>
            testing
            <div id="myExcelDiv" style="width: 402px; height: 346px"></div>
            <script type="text/javascript" src="https://onedrive.live.com/embed?resid=removed&authkey=removed&em=3&wdDivId=%22myExcelDiv%22&wdHideGridlines=1&wdHideHeaders=1&wdAllowInteractivity=1&wdAllowTyping=1"></script>
            <script type="text/javascript">
    
                    //the code from my first post goes here.
    
            </script>
    </body>

    Putting my document definition/elements before the embed script restores the app to functionality.  Thanks again for your assistance.  I'm considering my question answered at this time.

    MiltonCR

    • 편집됨 MiltonCR 2018년 6월 17일 일요일 오전 1:11
    • 답변으로 표시됨 MiltonCR 2018년 6월 17일 일요일 오전 1:12
    2018년 6월 17일 일요일 오전 1:08

모든 응답

  • I also had major issues with this (lost customers).

    I did get it to work (and able to use the EWA namespace) like this:

    var ewa = null;
    
    // Add event handler for onload event.
    if (window.attachEvent) 
    { 
        window.attachEvent("onload", ewaOnPageLoad);    
    } 
    else 
    { 
        window.addEventListener("DOMContentLoaded", ewaOnPageLoad, false); 
    }
    // Add event handler for applicationReady event.
    function ewaOnPageLoad()
    {
        if (typeof (Ewa) != "undefined")
        {
            Ewa.EwaControl.add_applicationReady(ewaApplicationReady);
        }
        else
        {
            console.log("Error - the EWA is not loaded.");
        }
        // Add additional page load code here.
    }
    
    function ewaApplicationReady()
    {
        // Get a reference to the Excel Services web part.
        ewa = Ewa.EwaControl.getInstances().getItem(0);
        console.log("EWA is loaded.");
        // Add other initialization logic here.
        ewa.add_activeCellChanged(cellChanged);
    
    }
        function cellChanged(rangeArgs)
        {
            // Use the RangeEventArgs object to get information about the range.
            var sheetName = rangeArgs.getRange().getSheet().getName();
            var col = rangeArgs.getRange().getColumn();
            var row = rangeArgs.getRange().getRow();
            var value = rangeArgs.getFormattedValues();
            console.log("The active cell is located at row " + (row + 1) + " and column " + (col + 1) + " with value '" + value + "'.");
            // ...
        }
    

    I get many CORS and "Precondition Failed" errors in the console. But it seems to work fine.

    I do wish that Microsoft would modernize this API (like add ability to get chart images, batching, etc.) and update the docs because it would be very useful.

    I would prefer if we could just use the more-powerful Office.js API to control embedded Excel on public web pages. It can control Excel Online with the add-in, but not publicly embedded Excel Online.


    Excel Services Analyst

    2018년 6월 14일 목요일 오후 7:01
  • Hi MiltonCR,

    Please using IE F12 to check if some errors occurs in the web page.

    There is not a official document talk about Microsoft abandoned the JavaScript API for Excel Online.

    To access Excel, please try to use Microsoft Graph and the Excel API.

    http://blog.atwork.at/post/2017/12/29/Access-files-in-OneDrive-or-SharePoint-with-Microsoft-Graph-and-the-Excel-API

    More information:

    https://docs.microsoft.com/en-us/previous-versions/office/developer/sharepoint-2010/hh315812(v%3Doffice.14)

    https://msdn.microsoft.com/en-us/library/office/ee589018.aspx?f=255&MSPPError=-2147217396

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    2018년 6월 15일 금요일 오전 6:37
    중재자
  • H-Logic,

    Thanks for the response!  Using your advice, I get "Uncaught TypeError: Cannot read property 'appendChild' of null" in the console when the parameterized link executes in my app.  The only difference I notice is the new embed code doesn't make a reference to the CDN-hosted ExcelJs library, where my apps still do.  Is it no longer required?

    Thanks in advance!

    2018년 6월 16일 토요일 오후 6:20
  • Below is the complete/minimum code for the page.  You get the first script from the OneDrive Excel embed configurator (select the JavaScript code).

    <!DOCTYPE html>
    <html lang="en">
        <head>
            <meta charset="utf-8" />
            <title></title>
        </head>
        <body>
            testing
            <div id="myExcelDiv" style="width: 402px; height: 346px"></div>
    <script type="text/javascript" src="https://onedrive.live.com/embed?resid=removed&authkey=removed&em=3&wdDivId=%22myExcelDiv%22&wdHideGridlines=1&wdHideHeaders=1&wdAllowInteractivity=1&wdAllowTyping=1"></script>

    <script type="text/javascript">

    //the code from my first post goes here.

        </script>
        </body>
    </html>


    Excel Services Analyst

    2018년 6월 16일 토요일 오후 7:02
  • H-Logic,

    Thanks for your help.  I noticed both your code and the embed code define the <body> document elements before the embed script:

    <body>
            testing
            <div id="myExcelDiv" style="width: 402px; height: 346px"></div>
            <script type="text/javascript" src="https://onedrive.live.com/embed?resid=removed&authkey=removed&em=3&wdDivId=%22myExcelDiv%22&wdHideGridlines=1&wdHideHeaders=1&wdAllowInteractivity=1&wdAllowTyping=1"></script>
            <script type="text/javascript">
    
                    //the code from my first post goes here.
    
            </script>
    </body>

    Putting my document definition/elements before the embed script restores the app to functionality.  Thanks again for your assistance.  I'm considering my question answered at this time.

    MiltonCR

    • 편집됨 MiltonCR 2018년 6월 17일 일요일 오전 1:11
    • 답변으로 표시됨 MiltonCR 2018년 6월 17일 일요일 오전 1:12
    2018년 6월 17일 일요일 오전 1:08
  • Hi,

    Glad to hear that you solve this issue, thanks for your sharing.

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    2018년 6월 19일 화요일 오전 8:30
    중재자