I'm delveloping JS Excel Addin, I need to run a function and show the results in taskpane. I wrote a function in taskpane.js and add it to taskpane load event but it won't run if taskpane is already opened. Is there any one to run taskpane function immediately from the button?
You need to set your project to use the shared Javascript runtime so you can call functions within the add-in from the manifest.
Try looking into this article: https://learn.microsoft.com/en-us/office/dev/add-ins/develop/configure-your-add-in-to-use-a-shared-runtime
By creating a new ribbon button with
<Action xsi:type="ExecuteFunction">
<FunctionName>action</FunctionName>
</Action>
you can call any function available in your addin after the addin is loaded.