Excel task pane add-in that uploads a W-2 (PDF or image), sends it to Azure AI Document Intelligence using the prebuilt model prebuilt-tax.us.w2, and writes extracted fields as one header row and one value row on the active worksheet (each new import is placed below existing content with a blank row in between).
- Node.js (v18+; v20+ recommended for some transitive tooling)
- Microsoft Excel — desktop (Windows or Mac) and/or Excel on the web (browser; Microsoft 365)
- An Azure AI Document Intelligence (or compatible Azure AI services) resource with endpoint and key
- In the Azure Portal, create a Document Intelligence / Azure AI services resource.
- Open Keys and Endpoint and copy Endpoint and Key 1.
- Paste them into
.env(see below). The service must support API version2024-11-30(Document Intelligence v4).
cp .env
# Edit .env: set AZURE_DI_ENDPOINT and AZURE_DI_KEYNever commit .env. Keys stay on the local HTTPS dev server only; the add-in bundle does not embed them.
npm install
npm startThis builds the task pane (dist/) and starts https://localhost:3000 with:
- Static files for the add-in (
taskpane.html,taskpane.js) POST /api/analyze— forwardsbase64Sourceto Azure, polls until analysis completes, returnsanalyzeResultJSON
Leave this process running while you use Excel.
With the server running:
npm run sideloadOr manually: Insert → Add-ins → Upload My Add-in (wording varies by platform) and choose manifest.xml.
Excel on the web: Open Excel online, create or open a workbook, then Insert → Add-ins → Upload my Add-in and select manifest.xml. Keep npm start running on the same machine; the browser loads the task pane from https://localhost:3000. After sideloading, use the Home tab → Tax import → W-2 import (same as desktop).
The manifest points the task pane to https://localhost:3000/taskpane.html. Trust the localhost certificate when the browser or Office prompts you.
The dev server uses HTTPS with a certificate signed by a local developer CA (office-addin-dev-certs). Chrome shows ERR_CERT_AUTHORITY_INVALID until that CA is trusted on your system (or imported into Chrome). This is expected for local development; it is not a bug in the app.
Fix (try in order):
-
Install the developer CA (recommended)
From the project root:npm run certs
On Linux, this usually needs elevated rights so the CA is installed system-wide. If it fails, run the same command with
sudo, or install manually (step 2). -
Trust the CA in Chrome (Linux manual example)
The CA file is:~/.office-addin-dev-certs/ca.crtIn Chrome: Settings → Privacy and security → Security → Manage certificates → Authorities → Import → select
ca.crt→ enable Trust this certificate for identifying websites → restart Chrome.
Then reloadhttps://localhost:3000/taskpane.html. -
Windows / macOS
Runnpm run certsfrom an elevated / admin terminal if prompted so the CA is added to the OS trust store; restart Chrome afterward. -
If the CA file does not exist yet
Start the server once (npm start); cert generation runs when certs are missing. Then runnpm run certsagain.
After the CA is trusted, the error should disappear for https://localhost:3000 and for the add-in task pane in Excel.
For faster iteration, run the dev server and rebuild the bundle on file changes:
npm run devIn another terminal, keep using npm run sideload once per Excel session, or reload the add-in from My Add-ins.
- You pick a file in the task pane; it is sent as base64 to
/api/analyze. - The server calls Azure Document Intelligence
prebuilt-tax.us.w2(tax model docs). - The client flattens
analyzeResult.documents[0].fieldsinto label/value pairs and writes them with the Excel JavaScript API.
Host the built dist/ assets and a secure backend that holds Azure credentials (for example Azure Functions + Key Vault) at stable HTTPS URLs, then update SourceLocation and icon URLs in manifest.xml accordingly.