Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Office AddIn Excel custom function not run correct #295

Closed
Edward-Zhou opened this issue Nov 24, 2021 · 3 comments
Closed

Office AddIn Excel custom function not run correct #295

Edward-Zhou opened this issue Nov 24, 2021 · 3 comments
Labels
Needs: triage 🔍 New issue, needs PM on rotation to triage ASAP

Comments

@Edward-Zhou
Copy link

Edward-Zhou commented Nov 24, 2021

*** This repo is for issues related to the current Excel Custom Functions sample. ***

If you have an issue running your custom function, please log an issue in the official office-js repo here: https://github.com/OfficeDev/office-js/issues ***

I am trying to implement Excel addin custom functions.

First, I refer this doc Tutorial: Create custom functions in Excel, after run this from VS Code, the custom function auto generated add did not show up when I type in Excel cell.

For the auto generated project, it contains command, taskpane and functions, and i found Configure your Office Add-in to use a shared JavaScript runtime, it seems I need to configure the shared runtime. After configuring the shared runtime by following this doc, I am able to see the add function in excel cell, but, it keeps #BYSY!, and return error below in webpack windows.

image

How can I run a custom functions in excel?

@ghost ghost added the Needs: triage 🔍 New issue, needs PM on rotation to triage ASAP label Nov 24, 2021
@millerds
Copy link
Contributor

At what point in the tutorial do you find things going wrong? If you create a project for custom functions using 'yo office' per the instructions it should work without having to do the shared runtime configuration separately. Are you trying to alter another project to include custom functions?

@Edward-Zhou
Copy link
Author

I followed steps below:

  • run npm install -g yo generator-office
  • create custom function project with yo office
  • change generated file manifest.xml with updating the <bt:String id="Functions.Namespace" DefaultValue="TestFun"/>
  • run npm run build
  • run npm start
  • after excel desktop open, enter formula add, there is no TestFun.add in the cell formula
    Here is cmd log:
Microsoft Windows [Version 10.0.19043.1288]
(c) Microsoft Corporation. All rights reserved.

C:\Users\edward\Meekou\New folder>yo office

     _-----_     ╭──────────────────────────╮
    |       |    │   Welcome to the Office  │
    |--(o)--|    │   Add-in generator, by   │
   `---------´   │ @OfficeDev! Let's create │
    ( _´U`_ )    │    a project together!   │
    /___A___\   /╰──────────────────────────╯
     |  ~  |
   __'.___.'__
 ´   `  |° ´ Y `

ApplicationInsights:CorrelationIdManager [
  Error: getaddrinfo ENOTFOUND dc.services.visualstudio.com
      at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:71:26)
      at GetAddrInfoReqWrap.callbackTrampoline (internal/async_hooks.js:130:17) {
    errno: -3008,
    code: 'ENOTFOUND',
    syscall: 'getaddrinfo',
    hostname: 'dc.services.visualstudio.com'
  }
]
? Choose a project type: Excel Custom Functions Add-in project
? Choose a script type: TypeScript
? What do you want to name your add-in? functiontest

----------------------------------------------------------------------------------

      Creating functiontest add-in for Excel using TypeScript and Excel-functions at C:\Users\edward\Meekou\New folder\functiontest

----------------------------------------------------------------------------------
C:\Users\edward\AppData\Roaming\nvm\v14.18.0\node_modules\generator-office\node_modules\cls-hooked\context.js:177
      throw exception;
      ^

Error: read ECONNRESET
    at TLSWrap.onStreamRead (internal/stream_base_commons.js:209:20)
    at TLSWrap.callbackTrampoline (internal/async_hooks.js:130:17)
Emitted 'error' event on Request instance at:
    at Request.onerror (internal/streams/legacy.js:62:12)
    at Request.emit (events.js:400:28)
    at Request.emit (domain.js:475:12)
    at Request.onRequestError (C:\Users\edward\AppData\Roaming\nvm\v14.18.0\node_modules\generator-office\node_modules\request\request.js:877:8)
    at ClientRequest.clsBind (C:\Users\edward\AppData\Roaming\nvm\v14.18.0\node_modules\generator-office\node_modules\cls-hooked\context.js:172:17)
    at ClientRequest.emit (events.js:412:35)
    at ClientRequest.emit (domain.js:475:12)
    at ClientRequest.emitted (C:\Users\edward\AppData\Roaming\nvm\v14.18.0\node_modules\generator-office\node_modules\emitter-listener\listener.js:134:21)
    at TLSSocket.socketErrorListener (_http_client.js:475:9)
    at TLSSocket.emit (events.js:400:28)
    at TLSSocket.emit (domain.js:475:12)
    at emitErrorNT (internal/streams/destroy.js:106:8)
    at emitErrorCloseNT (internal/streams/destroy.js:74:3)
    at processTicksAndRejections (internal/process/task_queues.js:82:21) {
  errno: -4077,
  code: 'ECONNRESET',
  syscall: 'read',
  'error@context': { _ns_name: 'AI-CLS-Session', id: 873 }
}

C:\Users\edward\Meekou\New folder>npm install -g yo generator-office
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated opn@6.0.0: The package has been renamed to `open`
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
C:\Program Files\nodejs\yo -> C:\Program Files\nodejs\node_modules\yo\lib\cli.js
C:\Program Files\nodejs\yo-complete -> C:\Program Files\nodejs\node_modules\yo\lib\completion\index.js

> yo@4.3.0 postinstall C:\Program Files\nodejs\node_modules\yo
> yodoctor


Yeoman Doctor
Running sanity checks on your system

√ No .bowerrc file in home directory
√ Global configuration file is valid
√ NODE_PATH matches the npm root
√ No .yo-rc.json file in home directory
√ Node.js version
√ npm version
√ yo version

Everything looks all right!
+ yo@4.3.0
+ generator-office@1.8.0
updated 2 packages in 695.792s

C:\Users\edward\Meekou\New folder>
C:\Users\edward\Meekou\New folder>
C:\Users\edward\Meekou\New folder>
C:\Users\edward\Meekou\New folder>
C:\Users\edward\Meekou\New folder>
C:\Users\edward\Meekou\New folder>yo office

     _-----_     ╭──────────────────────────╮
    |       |    │   Welcome to the Office  │
    |--(o)--|    │   Add-in generator, by   │
   `---------´   │ @OfficeDev! Let's create │
    ( _´U`_ )    │    a project together!   │
    /___A___\   /╰──────────────────────────╯
     |  ~  |
   __'.___.'__
 ´   `  |° ´ Y `

ApplicationInsights:CorrelationIdManager [
  Error: getaddrinfo ENOTFOUND dc.services.visualstudio.com
      at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:71:26)
      at GetAddrInfoReqWrap.callbackTrampoline (internal/async_hooks.js:130:17) {
    errno: -3008,
    code: 'ENOTFOUND',
    syscall: 'getaddrinfo',
    hostname: 'dc.services.visualstudio.com'
  }
]
? Choose a project type: Excel Custom Functions Add-in project
? Choose a script type: TypeScript
? What do you want to name your add-in? customfundemo

----------------------------------------------------------------------------------

      Creating customfundemo add-in for Excel using TypeScript and Excel-functions at C:\Users\edward\Meekou\New folder\customfundemo

----------------------------------------------------------------------------------


I'm all done. Running npm install for you to install the required dependencies. If this fails, try running the command yourself.



No change to package.json was detected. No package manager install will be executed.

> core-js-pure@3.15.1 postinstall C:\Users\edward\Meekou\New folder\customfundemo\node_modules\core-js-pure
> node -e "try{require('./postinstall')}catch(e){}"

Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!

The project needs your help! Please consider supporting of core-js on Open Collective or Patreon:
> https://opencollective.com/core-js
> https://www.patreon.com/zloirock

Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)


> core-js@3.17.3 postinstall C:\Users\edward\Meekou\New folder\customfundemo\node_modules\core-js
> node -e "try{require('./postinstall')}catch(e){}"

Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!

The project needs your help! Please consider supporting of core-js:
> https://opencollective.com/core-js
> https://patreon.com/zloirock
> https://paypal.me/zloirock
> bitcoin: bc1qlea7544qtsmj2rayg0lthvza9fau63ux0fstcz

Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

added 794 packages from 516 contributors and audited 802 packages in 75.494s

114 packages are looking for funding
  run `npm fund` for details

found 1 moderate severity vulnerability
  run `npm audit fix` to fix them, or `npm audit` for details
----------------------------------------------------------------------------------------------------------

      Congratulations! Your add-in has been created! Your next steps:

      1. Go the directory where your project was created:

         cd C:\Users\edward\Meekou\New folder\customfundemo

      2. Build your Excel Custom Functions taskpane add-in:

         npm run build

      3. Start the local web server and sideload the add-in:

         npm start

      4. Open the project in VS Code:

         code .

         For more information, visit http://code.visualstudio.com.

      Please visit https://docs.microsoft.com/office/dev/add-ins for more information about Office Add-ins.

----------------------------------------------------------------------------------------------------------


C:\Users\edward\Meekou\New folder>cd C:\Users\edward\Meekou\New folder\customfundemo

C:\Users\edward\Meekou\New folder\customfundemo>npm run build

> excel-custom-functions@2.0.0 build C:\Users\edward\Meekou\New folder\customfundemo
> webpack --mode production

Browserslist: caniuse-lite is outdated. Please run:
npx browserslist@latest --update-db

Why you should do it regularly:
https://github.com/browserslist/browserslist#browsers-data-updating
ApplicationInsights:CorrelationIdManager [
  Error: getaddrinfo ENOTFOUND dc.services.visualstudio.com
      at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:71:26)
      at GetAddrInfoReqWrap.callbackTrampoline (internal/async_hooks.js:130:17) {
    errno: -3008,
    code: 'ENOTFOUND',
    syscall: 'getaddrinfo',
    hostname: 'dc.services.visualstudio.com'
  }
]
assets by path assets/*.png 26.9 KiB 6 assets
assets by path *.js 141 KiB
  asset polyfill.js 138 KiB [emitted] [minimized] (name: polyfill) 1 related asset
  asset taskpane.js 2.27 KiB [emitted] [minimized] (name: taskpane) 1 related asset
  asset commands.js 597 bytes [emitted] [minimized] (name: commands) 1 related asset
  asset functions.js 540 bytes [emitted] [minimized] (name: functions) 1 related asset
assets by path *.html 2.45 KiB
  asset taskpane.html 1.77 KiB [emitted]
  asset functions.html 387 bytes [emitted]
  asset commands.html 313 bytes [emitted]
asset manifest.prod.xml 5.11 KiB [emitted] [from: manifest.xml] [copied]
asset functions.json 1.79 KiB [emitted]
asset 1fda685b81e1123773f6.css 1.48 KiB [emitted] [immutable] [from: src/taskpane/taskpane.css]
runtime modules 442 bytes 2 modules
modules by path ./node_modules/core-js/modules/*.js 243 KiB 230 modules
modules by path ./node_modules/core-js/internals/*.js 158 KiB 177 modules
modules by path ./src/ 7.76 KiB
  ./src/functions/functions.ts 1.88 KiB [built] [code generated]
  ./src/taskpane/taskpane.ts 4.84 KiB [built] [code generated]
  ./src/commands/commands.ts 1.04 KiB [built] [code generated]
./node_modules/core-js/stable/index.js 9.62 KiB [built] [code generated]
./node_modules/regenerator-runtime/runtime.js 24 KiB [built] [code generated]
webpack 5.52.1 compiled successfully in 8434 ms

C:\Users\edward\Meekou\New folder\customfundemo>npm run build

> excel-custom-functions@2.0.0 build C:\Users\edward\Meekou\New folder\customfundemo
> webpack --mode production

Browserslist: caniuse-lite is outdated. Please run:
npx browserslist@latest --update-db

Why you should do it regularly:
https://github.com/browserslist/browserslist#browsers-data-updating
ApplicationInsights:CorrelationIdManager [
  Error: getaddrinfo ENOTFOUND dc.services.visualstudio.com
      at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:71:26)
      at GetAddrInfoReqWrap.callbackTrampoline (internal/async_hooks.js:130:17) {
    errno: -3008,
    code: 'ENOTFOUND',
    syscall: 'getaddrinfo',
    hostname: 'dc.services.visualstudio.com'
  }
]
assets by status 1.48 KiB [cached] 1 asset
assets by path assets/*.png 26.9 KiB 6 assets
assets by path *.js 141 KiB
  asset polyfill.js 138 KiB [compared for emit] [minimized] (name: polyfill) 1 related asset
  asset taskpane.js 2.27 KiB [compared for emit] [minimized] (name: taskpane) 1 related asset
  asset commands.js 597 bytes [compared for emit] [minimized] (name: commands) 1 related asset
  asset functions.js 540 bytes [compared for emit] [minimized] (name: functions) 1 related asset
assets by path *.html 2.45 KiB
  asset taskpane.html 1.77 KiB [compared for emit]
  asset functions.html 387 bytes [compared for emit]
  asset commands.html 313 bytes [compared for emit]
asset manifest.prod.xml 5.11 KiB [emitted] [compared for emit] [from: manifest.xml] [copied]
asset functions.json 1.79 KiB [compared for emit]
runtime modules 442 bytes 2 modules
modules by path ./node_modules/core-js/modules/*.js 243 KiB 230 modules
modules by path ./node_modules/core-js/internals/*.js 158 KiB 177 modules
modules by path ./src/ 7.76 KiB
  ./src/functions/functions.ts 1.88 KiB [built] [code generated]
  ./src/taskpane/taskpane.ts 4.84 KiB [built] [code generated]
  ./src/commands/commands.ts 1.04 KiB [built] [code generated]
./node_modules/core-js/stable/index.js 9.62 KiB [built] [code generated]
./node_modules/regenerator-runtime/runtime.js 24 KiB [built] [code generated]
webpack 5.52.1 compiled successfully in 9059 ms

C:\Users\edward\Meekou\New folder\customfundemo>npm start

> excel-custom-functions@2.0.0 start C:\Users\edward\Meekou\New folder\customfundemo
> npm run build & office-addin-debugging start manifest.xml


> excel-custom-functions@2.0.0 build C:\Users\edward\Meekou\New folder\customfundemo
> webpack --mode production

Browserslist: caniuse-lite is outdated. Please run:
npx browserslist@latest --update-db

Why you should do it regularly:
https://github.com/browserslist/browserslist#browsers-data-updating
ApplicationInsights:CorrelationIdManager [
  Error: getaddrinfo ENOTFOUND dc.services.visualstudio.com
      at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:71:26)
      at GetAddrInfoReqWrap.callbackTrampoline (internal/async_hooks.js:130:17) {
    errno: -3008,
    code: 'ENOTFOUND',
    syscall: 'getaddrinfo',
    hostname: 'dc.services.visualstudio.com'
  }
]
assets by status 1.48 KiB [cached] 1 asset
assets by path assets/*.png 26.9 KiB 6 assets
assets by path *.js 141 KiB
  asset polyfill.js 138 KiB [compared for emit] [minimized] (name: polyfill) 1 related asset
  asset taskpane.js 2.27 KiB [compared for emit] [minimized] (name: taskpane) 1 related asset
  asset commands.js 597 bytes [compared for emit] [minimized] (name: commands) 1 related asset
  asset functions.js 540 bytes [compared for emit] [minimized] (name: functions) 1 related asset
assets by path *.html 2.45 KiB
  asset taskpane.html 1.77 KiB [compared for emit]
  asset functions.html 387 bytes [compared for emit]
  asset commands.html 313 bytes [compared for emit]
asset manifest.prod.xml 5.11 KiB [compared for emit] [from: manifest.xml] [copied]
asset functions.json 1.79 KiB [compared for emit]
runtime modules 442 bytes 2 modules
modules by path ./node_modules/core-js/modules/*.js 243 KiB 230 modules
modules by path ./node_modules/core-js/internals/*.js 158 KiB 177 modules
modules by path ./src/ 7.76 KiB
  ./src/functions/functions.ts 1.88 KiB [built] [code generated]
  ./src/taskpane/taskpane.ts 4.84 KiB [built] [code generated]
  ./src/commands/commands.ts 1.04 KiB [built] [code generated]
./node_modules/core-js/stable/index.js 9.62 KiB [built] [code generated]
./node_modules/regenerator-runtime/runtime.js 24 KiB [built] [code generated]
webpack 5.52.1 compiled successfully in 7870 ms
Debugging is being started...
App type: desktop
ApplicationInsights:CorrelationIdManager [
  Error: getaddrinfo ENOTFOUND dc.services.visualstudio.com
      at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:71:26)
      at GetAddrInfoReqWrap.callbackTrampoline (internal/async_hooks.js:130:17) {
    errno: -3008,
    code: 'ENOTFOUND',
    syscall: 'getaddrinfo',
    hostname: 'dc.services.visualstudio.com'
  }
]
Enabled debugging for add-in 9ab1472b-44a2-4e34-a079-0743ff51df66.
Starting the dev server... (webpack serve --mode development)
Sideloading the Office Add-in...
Debugging started.

C:\Users\edward\Meekou\New folder\customfundemo>

Here is running log in webpack

You already have trusted access to https://localhost.
Certificate: C:\Users\edward\.office-addin-dev-certs\localhost.crt
Key: C:\Users\edward\.office-addin-dev-certs\localhost.key
Browserslist: caniuse-lite is outdated. Please run:
npx browserslist@latest --update-db

Why you should do it regularly:
https://github.com/browserslist/browserslist#browsers-data-updating
<i> [webpack-dev-server] Project is running at:
<i> [webpack-dev-server] Loopback: https://localhost:3000/
<i> [webpack-dev-server] On Your Network (IPv4): https://10.90.93.143:3000/
<i> [webpack-dev-server] Content not from webpack is served from 'C:\Users\edward\Meekou\New folder\customfundemo' directory
ApplicationInsights:CorrelationIdManager [
  Error: getaddrinfo ENOTFOUND dc.services.visualstudio.com
      at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:71:26)
      at GetAddrInfoReqWrap.callbackTrampoline (internal/async_hooks.js:130:17) {
    errno: -3008,
    code: 'ENOTFOUND',
    syscall: 'getaddrinfo',
    hostname: 'dc.services.visualstudio.com'
  }
]
<i> [webpack-dev-middleware] wait until bundle finished: /dist/functions.js
<i> [webpack-dev-middleware] wait until bundle finished: /dist/functions.html
<i> [webpack-dev-middleware] wait until bundle finished: /dist/functions.json
<i> [webpack-dev-middleware] wait until bundle finished: /dist/functions.js.map
<i> [webpack-dev-middleware] wait until bundle finished: /taskpane.html?_host_Info=Excel$Win32$16.01$en-US$$$$2
assets by path assets/*.png 26.9 KiB 6 assets
assets by path *.js 1.68 MiB
  asset polyfill.js 940 KiB [emitted] (name: polyfill) 1 related asset
  asset taskpane.js 261 KiB [emitted] (name: taskpane) 1 related asset
  asset functions.js 258 KiB [emitted] (name: functions) 1 related asset
  asset commands.js 257 KiB [emitted] (name: commands) 1 related asset
assets by path *.html 3.51 KiB
  asset taskpane.html 2.53 KiB [emitted]
  asset functions.html 527 bytes [emitted]
  asset commands.html 485 bytes [emitted]
asset manifest.dev.xml 5.1 KiB [emitted] [from: manifest.xml] [copied]
asset functions.json 1.79 KiB [emitted]
asset 1fda685b81e1123773f6.css 1.48 KiB [emitted] [immutable] [from: src/taskpane/taskpane.css]
runtime modules 109 KiB 52 modules
modules by path ./node_modules/core-js/ 411 KiB 408 modules
modules by path ./node_modules/webpack-dev-server/client/ 51 KiB 12 modules
modules by path ./node_modules/webpack/hot/*.js 4.3 KiB 4 modules
modules by path ./node_modules/html-entities/lib/*.js 81.3 KiB 4 modules
modules by path ./src/ 7.76 KiB 3 modules
modules by path ./node_modules/url/ 37.4 KiB 3 modules
modules by path ./node_modules/querystring/*.js 4.51 KiB
  ./node_modules/querystring/index.js 127 bytes [built] [code generated]
  ./node_modules/querystring/decode.js 2.34 KiB [built] [code generated]
  ./node_modules/querystring/encode.js 2.04 KiB [built] [code generated]
./node_modules/regenerator-runtime/runtime.js 24 KiB [built] [code generated]
./node_modules/ansi-html-community/index.js 4.16 KiB [built] [code generated]
./node_modules/events/events.js 14.5 KiB [built] [code generated]
webpack 5.52.1 compiled successfully in 60639 ms
ApplicationInsights:Sender [
  'Ingestion endpoint could not be reached 5 consecutive times. There may be resulting telemetry loss. Most recent error:',
  Error: getaddrinfo ENOTFOUND dc.services.visualstudio.com
      at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:71:26)
      at GetAddrInfoReqWrap.callbackTrampoline (internal/async_hooks.js:130:17) {
    errno: -3008,
    code: 'ENOTFOUND',
    syscall: 'getaddrinfo',
    hostname: 'dc.services.visualstudio.com'
  }
]

Here is my screenshot result.
image

@millerds
Copy link
Contributor

I can see the existing function reference there from before the namespace change. You need to clear out the WEF cache by deleting the "C:\Users<user>\AppData\Local\Microsoft\Office\16.0\Wef" folder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs: triage 🔍 New issue, needs PM on rotation to triage ASAP
Projects
None yet
Development

No branches or pull requests

2 participants