template for porting excel VBA to RESTful API
Everyone loves Excel, but VBA is disliked. In particular, VBA is difficult to debug and manage code. So I came up with the idea of preparing a backend server and using Excel with custom functions as the frontend. In this Excel, REST-API is only executed from VBA via HTTP, the actual calculation is executed on the backend server, and only the result is returned to Excel again.
Also, if you are using Office 365 or later, you can use JavaScript in addition to VBA, so you can display the results in real time by Websocket communication.
Build FastAPI or Flask, a micro web framework written in Python, and send and receive messages converted to JSON format by VBA. Supported not only REST-API but also WebSocket
- FastAPI https://fastapi.tiangolo.com/ja/
- flask-restx https://flask-restx.readthedocs.io/en/latest/
- websockets https://websockets.readthedocs.io/en/stable/intro.html
- VBA-JSON
https://github.com/VBA-tools/VBA-JSON
- "Excel でカスタム関数を作成する"
- "Excel JavaScript API を使用した基本的なプログラミングの概念"
https://docs.microsoft.com/ja-jp/office/dev/add-ins/excel/excel-add-ins-core-concepts
- "カスタム関数でデータを受信して処理する" (by JavaScript)
https://docs.microsoft.com/ja-jp/office/dev/add-ins/excel/custom-functions-web-reqs