Skip to content

benc-uk/excel-mtg

Repository files navigation

Magic The Gathering API Excel Add In

This is an Excel add-in for enriching spreadsheets using Data Types and extracting information about Magic The Gathering cards. It can lookup cards by name Created purely to learn Excel add-in development, this has dubious real world applicability!

It uses the REST API of https://docs.magicthegathering.io/

screen 3 screen 1 screen 2

Developement with WSL

Pre-reqs and setup

From WSL shell/terminal

Excel document URL:

  • Copy .env.sample to .env
  • Edit .env
    • Add the URL of an online Excel document as the value of DOCUMENT_URL
    • To get this URL: Open Office on the web or OneDrive. Using the "Create" option, make a document in Excel. In this new document, select "Share", select "Copy Link", and copy the URL.

Generate certs:

  • Ensure certs are generated by running npx office-addin-dev-certs install
  • Check with ls -l ~/.office-addin-dev-certs
  • Edit webpack.config.js in root of project and add host: "0.0.0.0", to the devServer configuration section (around line 97+)
  • Run npm run dev-server (also from root of project)

From Windows

  • Open path \\wsl.localhost\Ubuntu\home\{username}\.office-addin-dev-certs in file explorer (change the distro and username to match yours)
  • Double click the ca.crt file
    • Click 'Install Certificate'
    • IMPORTANT: Place the certificate in the "Current User" and "Trusted Root Certification Authorities" store, do NOT pick automatic
    • Complete the import process
  • Double click localhost.crt
    • Click 'Install Certificate'
    • Place the certificate in the "Current User" and pick automatic for the store
    • Complete the import process
  • Open a browser window and navigate to https://127.0.0.1:3000/manifest.xml Note. It is critical you use HTTPS and 127.0.0.1 not localhost
    • The XML file should be shown and you should NOT get any browser or certificate warnings

Running with Web Sideloading

Once all the pre-reqs are done

  • Make sure the dev server still running, if not start it in a separate terminal with npm run dev-server
  • Run npm run start:web

Deploying to Azure

Quick notes:

  • Create a new Static Web App az staticwebapp create -n MyStaticAppName -g MyExistingRg
  • Install the SWA CLI
  • Edit swa-cli.config.json and change appName and resourceGroup to match what you have deployed.
  • Run npm run build
  • Run swa deploy --no-use-keychain

Adding and using deployed add-in

  • Open new Excel web document, https://www.office.com/launch/excel?auth=2
  • Insert > Add-Ins > Manage My Add-Ins > Upload My Add-In
  • Browse to the manifest.xml in the dist folder NOT the one in the repo root
  • Use the new add-in :)

About

Excel add-in for enriching spreadsheets using Data Types and extracting information about Magic The Gathering cards

Topics

Resources

Stars

Watchers

Forks