Here are the ways I have tried in a +page.svelte
onMount(async () => {
const module = await import('https://appsforoffice.microsoft.com/lib/1/hosted/office.js');
});
This seems to try to load but has the following error - "Uncaught (in promise) Office Web Extension script library file name should be office.js or office.debug.js."
Also tried
<script type="text/javascript" src="https://appsforoffice.microsoft.com/lib/1.1/hosted/office.js">
import { browser } from '$app/environment';
import { onMount } from 'svelte';
let isOfficeInitialized = false;
if (browser) {
console.log("browser load");
window.onload = function () {
console.log("window onload");
const Office = window.Office;
Office.onReady(() => {
console.log("Office Ready");
isOfficeInitialized = true;
});
}
}
console log shows "browser load" but not "window onload"
and
<script type="text/javascript" src="https://appsforoffice.microsoft.com/lib/1.1/hosted/office.js">
import { browser } from '$app/environment';
import { onMount } from 'svelte';
let isOfficeInitialized = false;
if (browser) {
console.log('load in browser');
const Office = window.Office;
if (Office) {
console.log('Office assigned');
Office.onReady(() => {
console.log('Office Ready');
isOfficeInitialized = true;
});
}
}
console log shows "load in browser" but not "Office assigned"
Has anyone been able to use office.js in SvelteKit? There is a post, Can you build an Excel task pane add-in with Svelte?, about using Svelte for a web add-in but I could not find if it has been done using SvelteKit. I might be going about it wrong so any input would be appreciated.