From 1e7586dda7c22ecf88429f6fa8741e36d1ee9e5d Mon Sep 17 00:00:00 2001 From: Felix Zumstein Date: Mon, 9 Dec 2024 17:26:18 +0100 Subject: [PATCH] only reload custom functions in dev --- app/static/js/core/reload-custom-functions.js | 8 ++++++++ app/templates/base.html | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/static/js/core/reload-custom-functions.js b/app/static/js/core/reload-custom-functions.js index da1bd5be..4035502e 100644 --- a/app/static/js/core/reload-custom-functions.js +++ b/app/static/js/core/reload-custom-functions.js @@ -1,5 +1,13 @@ async function reloadCustomFunctions() { // Unofficial API: https://github.com/OfficeDev/office-js/issues/3486 + // This causes issues when opening a workbook in a running instance of Excel. If + // Excel is completely closed, it does load the add-in, but not if it is already + // running. + // Custom functions will show #NAME? until the task pane is opened + // manually. That's why this is only loaded in "dev" environment. While + // await Office.addin.setStartupBehavior(Office.StartupBehavior.load); would solve + // the issue, it would make every workbook, which is opened while the add-in is + // installed, look for the add-in when reopened. await Office.onReady(); let jsonMetadataString, code; diff --git a/app/templates/base.html b/app/templates/base.html index b6a46baf..b0795910 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -54,7 +54,9 @@ {# Load Custom Functions #} {% block custom_functions_code %} - + {% if settings.environment == "dev" %} + + {% endif %} {% endblock custom_functions_code %} {# Bootstrap with the xlwings theme #} {% if settings.enable_bootstrap %}