Office js загружается вне Excel при установке TaskPane в iframe - PullRequest
2 голосов
/ 24 апреля 2020

Определение панели задач в iframe приведет к тому, что Office js не будет работать в Excel. Что приводит к «Excel» не определено. Я хочу проверить, является ли это iframe известным ограничением или ошибкой.

TaskPane. html

<!DOCTYPE html>
<html>
   <head>
      <title>HTML Iframes</title>
   </head>
   <body>
      <iframe src = "./randomGenerator.html" width = "555" height = "200">
         Sorry your browser does not support inline frames.
      </iframe>
   </body>
</html>

randomGenerator

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="https://appsforoffice.microsoft.com/lib/1/hosted/Office.js" type="text/javascript"></script>
</head>
<body>

<p id="output">hello</p>

</body>
    <script type="text/javascript">
        Office.onReady(info => {
            if (info.host === Office.HostType.Excel) {
                document.getElementById("output").innerHTML = "I am in Excel";
            } else {
                document.getElementById("output").innerHTML = "out of excel";
            }
        });
    </script>
</html>

Результат

Office. js загружен вне Excel

...