Shiv Yadav
Shiv Yadav

Reputation: 311

How to create custom function in excel add-in using office JS in already existing react project

I am new to a custom function. I already have a react project. I want to use one custom function in that project. I have read the document about it. It has two options either you can create a react js project or you can create custom function project.

can anyone guide me on "how to create a custom function in react project"?

Upvotes: 0

Views: 360

Answers (2)

Eugene Astafiev
Eugene Astafiev

Reputation: 49397

Office add-ins that combine two kind of features - custom functions and, for example, react web app are run all of its code in a single shared runtime. A shared runtime isn't a type of runtime. It refers to a browser-type runtime that's being shared by features of the add-in that would otherwise each have their own runtime. Specifically, you have the option of configuring the add-in's task pane and function commands to share a runtime. In an Excel add-in, you can configure custom functions to share the runtime of a task pane or function command or both. When you do this, the custom functions are running in a browser-type runtime, instead of a JavaScript-only runtime as it otherwise would.

See Configure your add-in to use a shared runtime for information about the benefits and limitations of sharing runtimes and instructions for configuring the add-in to use a shared runtime. In brief, the JavaScript-only runtime uses less memory and starts up faster, but has fewer features.

Upvotes: 1

Jakob Nielsen-MSFT
Jakob Nielsen-MSFT

Reputation: 514

Yadav, here is one option:

  1. Generate a new add-in project using the yo office "Excel Custom Functions using a Shared Runtime" template.
  2. Compare the following files with what you already have in your add-in project to identify the changes you need to make to add custom functions to your project: manifest.xaml, package.json, webpack.config.js.
  3. Copy new files that identified in step 2 from the project you made in step 1 to your add-in project.
  4. Make the changes identified in step 2.

Upvotes: 2

Related Questions