# Excel Local AI Add-in — Install & Troubleshoot ## Prerequisites - LM Studio running with local server on port 1234 - nginx reverse proxy from :1235 → :1234 with HTTPS + CORS ## Step 1: Trust the SSL certificate ```bash # System-level trust (Excel's webview checks this) sudo security add-trusted-cert -d -r trustRoot \ -k /Library/Keychains/System.keychain \ /opt/homebrew/etc/nginx/lm-studio.crt # User-level trust (belt and suspenders) security add-trusted-cert -d -r trustRoot \ -k ~/Library/Keychains/login.keychain-db \ /opt/homebrew/etc/nginx/lm-studio.crt ``` ## Step 2: Configure nginx to serve these files Add this to your nginx config (same server block that proxies :1235 → :1234): ```nginx # In the server block for port 1235: # Serve add-in files location /taskpane.html { alias /Users/YOUR_USERNAME/excel-local-ai-addin/taskpane.html; add_header Access-Control-Allow-Origin "*"; } location /functions.json { alias /Users/YOUR_USERNAME/excel-local-ai-addin/functions.json; add_header Access-Control-Allow-Origin "*"; } location /manifest.xml { alias /Users/YOUR_USERNAME/excel-local-ai-addin/manifest.xml; add_header Access-Control-Allow-Origin "*"; } # Icon placeholders (1x1 transparent PNG base64) location /icon-16.png { return 200 "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH5QEXBSsYkYMg5wAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAAAVSURBVDjLY2AYBaNgFIyCUTAKRsEoAgAHBAABKOTFyAAAAABJRU5ErkJggg=="; add_header Content-Type image/png; } location /icon-32.png { return 200 "iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH5QEXBSsYkYMg5wAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAAAVSURBVDjLY2AYBaNgFIyCUTAKRsEoAgAHBAABKOTFyAAAAABJRU5ErkJggg=="; add_header Content-Type image/png; } location /icon-64.png { return 200 "iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH5QEXBSsYkYMg5wAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAAAVSURBVDjLY2AYBaNgFIyCUTAKRsEoAgAHBAABKOTFyAAAAABJRU5ErkJggg=="; add_header Content-Type image/png; } location /icon-128.png { return 200 "iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH5QEXBSsYkYMg5wAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAAAVSURBVDjLY2AYBaNgFIyCUTAKRsEoAgAHBAABKOTFyAAAAABJRU5ErkJggg=="; add_header Content-Type image/png; } # Existing proxy location /v1/ { proxy_pass http://127.0.0.1:1234/v1/; proxy_set_header Host $host; add_header Access-Control-Allow-Origin "*" always; add_header Access-Control-Allow-Methods "GET, POST, OPTIONS" always; add_header Access-Control-Allow-Headers "Content-Type, Authorization" always; if ($request_method = OPTIONS) { return 204; } } ``` Then reload: ```bash sudo nginx -t && sudo nginx -s reload ``` ## Step 3: Copy the add-in files ```bash # Copy add-in files to your home folder (nginx will serve from here) mkdir -p ~/excel-local-ai-addin cp /tmp/excel-local-ai-addin/* ~/excel-local-ai-addin/ ``` ## Step 4: Sideload into Excel ```bash # Create the wef folder if it doesn't exist mkdir -p ~/Library/Containers/com.microsoft.Excel/Data/Documents/wef/ # Copy the manifest cp ~/excel-local-ai-addin/manifest.xml \ ~/Library/Containers/com.microsoft.Excel/Data/Documents/wef/local-ai-manifest.xml ``` ## Step 5: Restart Excel and Test 1. **FULLY QUIT** Excel (Cmd+Q — don't just close the window!) 2. Wait 5 seconds 3. Reopen Excel 4. Go to **Home tab → Add-ins → Local AI** (should appear) 5. Click "AI Chat" in the ribbon 6. Type `=AI_LOCAL("What is a p-value?")` in any cell --- ## Troubleshooting | Symptom | Fix | |---|---| | Add-in doesn't appear in Home → Add-ins | Restart nginx (`sudo nginx -s reload`), verify `https://127.0.0.1:1235/taskpane.html` loads in Safari | | `#NAME?` error showing `_xldudf_AI_LOCAL` | Clear Office cache: Delete `~/Library/Containers/com.microsoft.Excel/Data/Library/Caches/`, FULL quit, reopen | | `#VALUE!` or `#ERROR:` in cell | Check nginx is running, verify `curl -k https://127.0.0.1:1235/v1/models` works | | "Network request failed" | Certificate not trusted at system level. Re-run Step 1. | | Add-in loads but custom functions don't register | Make sure SharedRuntime is enabled. Check manifest has `` | | Manifest XML fails to load | Validate: `xmllint --noout manifest.xml` |