Skip to content

Commit

Permalink
only reload custom functions in dev
Browse files Browse the repository at this point in the history
  • Loading branch information
fzumstein committed Dec 9, 2024
1 parent 51cf69b commit 1e7586d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 8 additions & 0 deletions app/static/js/core/reload-custom-functions.js
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
4 changes: 3 additions & 1 deletion app/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@
{# Load Custom Functions #}
{% block custom_functions_code %}
<script src="{{ url_for('custom_functions_code') }}" defer></script>
<script src="{{ url_for('static', path='/js/core/reload-custom-functions.js') }}" defer></script>
{% if settings.environment == "dev" %}
<script src="{{ url_for('static', path='/js/core/reload-custom-functions.js') }}" defer></script>
{% endif %}
{% endblock custom_functions_code %}
{# Bootstrap with the xlwings theme #}
{% if settings.enable_bootstrap %}
Expand Down

0 comments on commit 1e7586d

Please sign in to comment.