calc-rtd 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- calc_rtd-0.1.0/LICENSE +21 -0
- calc_rtd-0.1.0/PKG-INFO +178 -0
- calc_rtd-0.1.0/README.md +160 -0
- calc_rtd-0.1.0/pyproject.toml +33 -0
- calc_rtd-0.1.0/setup.cfg +4 -0
- calc_rtd-0.1.0/src/calc_rtd.egg-info/PKG-INFO +178 -0
- calc_rtd-0.1.0/src/calc_rtd.egg-info/SOURCES.txt +20 -0
- calc_rtd-0.1.0/src/calc_rtd.egg-info/dependency_links.txt +1 -0
- calc_rtd-0.1.0/src/calc_rtd.egg-info/entry_points.txt +2 -0
- calc_rtd-0.1.0/src/calc_rtd.egg-info/requires.txt +3 -0
- calc_rtd-0.1.0/src/calc_rtd.egg-info/top_level.txt +1 -0
- calc_rtd-0.1.0/src/calc_rtd_bridge/__init__.py +3 -0
- calc_rtd-0.1.0/src/calc_rtd_bridge/__main__.py +5 -0
- calc_rtd-0.1.0/src/calc_rtd_bridge/cli.py +227 -0
- calc_rtd-0.1.0/src/calc_rtd_bridge/client.py +55 -0
- calc_rtd-0.1.0/src/calc_rtd_bridge/com_driver.py +237 -0
- calc_rtd-0.1.0/src/calc_rtd_bridge/core.py +215 -0
- calc_rtd-0.1.0/src/calc_rtd_bridge/protocol.py +150 -0
- calc_rtd-0.1.0/src/calc_rtd_bridge/rtd_host.py +174 -0
- calc_rtd-0.1.0/src/calc_rtd_bridge/server.py +181 -0
- calc_rtd-0.1.0/src/calc_rtd_bridge/sim.py +88 -0
- calc_rtd-0.1.0/tests/test_bridge.py +245 -0
calc_rtd-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 calc-rtd contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
calc_rtd-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: calc-rtd
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Use Excel RTD (RealTimeData) servers from LibreOffice Calc: the bridge that hosts the RTD server
|
|
5
|
+
License: MIT
|
|
6
|
+
Project-URL: Homepage, https://github.com/andreydani/calc-rtd
|
|
7
|
+
Project-URL: Issues, https://github.com/andreydani/calc-rtd/issues
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Topic :: Office/Business :: Financial :: Spreadsheet
|
|
13
|
+
Requires-Python: >=3.9
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Requires-Dist: comtypes>=1.2; sys_platform == "win32"
|
|
17
|
+
Dynamic: license-file
|
|
18
|
+
|
|
19
|
+
# calc-rtd
|
|
20
|
+
|
|
21
|
+
**Use Excel RTD (RealTimeData) servers from LibreOffice Calc**, with the formula you already know:
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
=RTD("Vendor.ProgID";;"TOPIC1";"TOPIC2")
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Many market-data terminals and industrial tools publish live data to spreadsheets through an
|
|
28
|
+
*RTD server*, a COM component that Microsoft Excel loads for its `RTD()` function. LibreOffice
|
|
29
|
+
Calc has no such function. calc-rtd adds it: a Calc extension provides `RTD()`, and a small
|
|
30
|
+
Windows bridge loads the vendor's RTD server and plays Excel's part of the conversation.
|
|
31
|
+
|
|
32
|
+
> **Status: experimental (0.1).** Verified end to end on Windows with LibreOffice and a
|
|
33
|
+
> third-party .NET RTD server, and on Linux with the built-in simulated source.
|
|
34
|
+
|
|
35
|
+
calc-rtd is an independent project. It is not affiliated with or endorsed by Microsoft or
|
|
36
|
+
The Document Foundation. It contains no Microsoft code: it implements the client side of the
|
|
37
|
+
publicly documented `IRtdServer` interface.
|
|
38
|
+
|
|
39
|
+
## How it works
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
LibreOffice Calc bridge (Windows process) RTD server
|
|
43
|
+
+------------------+ local TCP +--------------------------+ COM +----------------+
|
|
44
|
+
| calc-rtd.oxt |<--------------->| calc-rtd-bridge serve |<----->| IRtdServer |
|
|
45
|
+
| =RTD(...) | JSON lines | acts as Excel would | | (vendor's own) |
|
|
46
|
+
+------------------+ 127.0.0.1:47365 +--------------------------+ +----------------+
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
- **Extension** (`extension/`): a Python add-in that registers the `RTD` function and returns
|
|
50
|
+
an `XVolatileResult`, Calc's mechanism for values that change on their own. Standard library
|
|
51
|
+
only, so it runs on the Python bundled with LibreOffice.
|
|
52
|
+
- **Bridge** (`src/calc_rtd_bridge/`): a separate process that creates the RTD server through
|
|
53
|
+
COM and drives it the way Excel does (`ServerStart`, `ConnectData`, `UpdateNotify`,
|
|
54
|
+
`RefreshData`, `Heartbeat`...). Keeping it outside LibreOffice means it can match the RTD
|
|
55
|
+
server's bitness (32/64-bit), and a misbehaving server cannot take the spreadsheet down.
|
|
56
|
+
|
|
57
|
+
## Install
|
|
58
|
+
|
|
59
|
+
Requirements: Windows and LibreOffice 4.0 or later.
|
|
60
|
+
|
|
61
|
+
1. Download the extension from the [Releases](https://github.com/andreydani/calc-rtd/releases)
|
|
62
|
+
page:
|
|
63
|
+
- `calc-rtd-win64.oxt` or `calc-rtd-win32.oxt` include the bridge as a standalone
|
|
64
|
+
program; nothing else to install. Pick the one that matches your RTD server (see below).
|
|
65
|
+
- `calc-rtd.oxt` contains no executable. It needs Python 3.9+ and
|
|
66
|
+
`pip install calc-rtd`; choose it if you prefer not to run a downloaded `.exe`.
|
|
67
|
+
2. In LibreOffice: **Tools > Extensions > Add**, select the file, then restart LibreOffice
|
|
68
|
+
(including the Quickstarter, if you use it).
|
|
69
|
+
|
|
70
|
+
> **32-bit or 64-bit?** An RTD server shipped as a DLL only loads into a process of the same
|
|
71
|
+
> bitness as the Excel it was installed for; that is the bridge you need (it does not have to
|
|
72
|
+
> match LibreOffice). If unsure, try `win64` first. Out-of-process (EXE) servers work with both.
|
|
73
|
+
|
|
74
|
+
> **The bundled program is not code-signed.** Windows SmartScreen or your antivirus may warn
|
|
75
|
+
> about it. It is built from this repository by GitHub Actions; use the Python-only extension
|
|
76
|
+
> if you would rather not run it.
|
|
77
|
+
|
|
78
|
+
> **Do not "Run as administrator".** Run LibreOffice (and the bridge) at the same privilege
|
|
79
|
+
> level as the application that feeds the RTD server. An elevated process cannot see the COM
|
|
80
|
+
> objects of a normal one, and the server fails with "Class not registered".
|
|
81
|
+
|
|
82
|
+
## Use
|
|
83
|
+
|
|
84
|
+
In Calc, type the formula as you would in Excel:
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
=RTD("Vendor.ProgID";;"ACME";"LAST")
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
The extension starts the bridge in the background the first time an `RTD` formula is
|
|
91
|
+
calculated, and the bridge exits about a minute after LibreOffice closes. Cells show `#N/A`
|
|
92
|
+
until the first value arrives, as in Excel; the very first start can take a few seconds. Server errors appear as text starting with
|
|
93
|
+
`#RTD:`, and `#RTD: bridge offline` means the bridge could not be started or reached.
|
|
94
|
+
|
|
95
|
+
Excel writes the function as `_xlfn.RTD` on the clipboard, and that spelling is accepted too.
|
|
96
|
+
If cells copied from Excel still show `#NAME?`, Calc kept them as unparsed text: use
|
|
97
|
+
**Edit > Find & Replace**, search for `_xlfn.` and replace it with nothing ("Search in:
|
|
98
|
+
Formulas"), which makes Calc read the formulas again.
|
|
99
|
+
|
|
100
|
+
You can also run the bridge yourself, for example to see its log:
|
|
101
|
+
|
|
102
|
+
```bat
|
|
103
|
+
calc-rtd-bridge -v serve
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Environment variables, read by the extension and the bridge:
|
|
107
|
+
|
|
108
|
+
| Variable | Meaning |
|
|
109
|
+
|---|---|
|
|
110
|
+
| `CALC_RTD_PORT` | TCP port on 127.0.0.1 (default 47365) |
|
|
111
|
+
| `CALC_RTD_AUTOSTART=0` | the extension never starts the bridge |
|
|
112
|
+
| `CALC_RTD_BRIDGE_CMD` | command line the extension uses to start the bridge |
|
|
113
|
+
| `CALC_RTD_TOKEN_FILE` | location of the authentication token |
|
|
114
|
+
|
|
115
|
+
### Simulated source (any OS, no RTD server needed)
|
|
116
|
+
|
|
117
|
+
```
|
|
118
|
+
=RTD("calcrtd.sim";;"clock") current time, every second
|
|
119
|
+
=RTD("calcrtd.sim";;"counter";0.2) 1, 2, 3... every 0.2 s
|
|
120
|
+
=RTD("calcrtd.sim";;"random";10;20) random number between 10 and 20
|
|
121
|
+
=RTD("calcrtd.sim";;"walk";"ACME";38.5) random walk starting at 38.5
|
|
122
|
+
=RTD("calcrtd.sim";;"echo";"hello") fixed text
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Try an RTD server without LibreOffice
|
|
126
|
+
|
|
127
|
+
`monitor` loads an RTD server directly and prints what Calc would receive. Use it to check
|
|
128
|
+
that a given server works with the bridge:
|
|
129
|
+
|
|
130
|
+
```bat
|
|
131
|
+
calc-rtd-bridge monitor "=RTD(Vendor.ProgID;;ACME;LAST)" --seconds 30
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
The formula can be pasted from Excel (`,` or `;` separators, quotes optional). For several
|
|
135
|
+
formulas use `--file formulas.txt` (one per line) or `--progid X --topics A B`. Put `-v` before
|
|
136
|
+
`monitor` for detailed logging. The exit code is 0 if updates were received.
|
|
137
|
+
|
|
138
|
+
`calc-rtd-bridge watch ...` does the same through the socket of a running bridge.
|
|
139
|
+
|
|
140
|
+
## Known limitations
|
|
141
|
+
|
|
142
|
+
- **Windows only** for real servers: RTD is a COM technology.
|
|
143
|
+
- **Excel files:** Calc imports RTD formulas in `.xlsx` files as `#NAME?`; re-enter them
|
|
144
|
+
(see the Find & Replace tip above). Saving to `.xlsx` does not produce a formula Excel
|
|
145
|
+
understands. Use `.ods`.
|
|
146
|
+
- Some vendors tie their RTD server to their own Excel add-in (login, licensing) and may
|
|
147
|
+
refuse a host other than Excel. Your data vendor's terms of use still apply.
|
|
148
|
+
- Out-of-process RTD servers need the RTD interfaces registered for marshalling, which
|
|
149
|
+
installing Excel does.
|
|
150
|
+
- The bridge listens on `127.0.0.1` only and requires a random token stored in a file that
|
|
151
|
+
only your user account can read (`%APPDATA%\calc-rtd\token`). Programs running under your
|
|
152
|
+
own account can still read it; the token keeps other accounts on the machine out.
|
|
153
|
+
- Updates are delivered at most every `--throttle` milliseconds (default 500; Excel uses 2000).
|
|
154
|
+
|
|
155
|
+
## Development
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
pip install -e . pytest
|
|
159
|
+
pytest # bridge, protocol, RTD host with a fake driver
|
|
160
|
+
python tools/build_oxt.py # builds dist/calc-rtd.oxt (no LibreOffice SDK needed)
|
|
161
|
+
unopkg add -f dist/calc-rtd.oxt
|
|
162
|
+
python tests/integration_libreoffice.py # end to end against a headless LibreOffice
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
To use the bridge from source instead of a release:
|
|
166
|
+
|
|
167
|
+
```bat
|
|
168
|
+
pip install git+https://github.com/andreydani/calc-rtd
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
`tools/build_oxt.py` writes the UNO type library (`.rdb`) directly in its binary format, so
|
|
172
|
+
`unoidl-write` from the SDK is not required. The protocol between extension and bridge is
|
|
173
|
+
documented in `src/calc_rtd_bridge/protocol.py`; any program can be a client of the bridge.
|
|
174
|
+
|
|
175
|
+
## License
|
|
176
|
+
|
|
177
|
+
MIT. Microsoft and Excel are trademarks of the Microsoft group of companies; LibreOffice is a
|
|
178
|
+
trademark of The Document Foundation.
|
calc_rtd-0.1.0/README.md
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# calc-rtd
|
|
2
|
+
|
|
3
|
+
**Use Excel RTD (RealTimeData) servers from LibreOffice Calc**, with the formula you already know:
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
=RTD("Vendor.ProgID";;"TOPIC1";"TOPIC2")
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Many market-data terminals and industrial tools publish live data to spreadsheets through an
|
|
10
|
+
*RTD server*, a COM component that Microsoft Excel loads for its `RTD()` function. LibreOffice
|
|
11
|
+
Calc has no such function. calc-rtd adds it: a Calc extension provides `RTD()`, and a small
|
|
12
|
+
Windows bridge loads the vendor's RTD server and plays Excel's part of the conversation.
|
|
13
|
+
|
|
14
|
+
> **Status: experimental (0.1).** Verified end to end on Windows with LibreOffice and a
|
|
15
|
+
> third-party .NET RTD server, and on Linux with the built-in simulated source.
|
|
16
|
+
|
|
17
|
+
calc-rtd is an independent project. It is not affiliated with or endorsed by Microsoft or
|
|
18
|
+
The Document Foundation. It contains no Microsoft code: it implements the client side of the
|
|
19
|
+
publicly documented `IRtdServer` interface.
|
|
20
|
+
|
|
21
|
+
## How it works
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
LibreOffice Calc bridge (Windows process) RTD server
|
|
25
|
+
+------------------+ local TCP +--------------------------+ COM +----------------+
|
|
26
|
+
| calc-rtd.oxt |<--------------->| calc-rtd-bridge serve |<----->| IRtdServer |
|
|
27
|
+
| =RTD(...) | JSON lines | acts as Excel would | | (vendor's own) |
|
|
28
|
+
+------------------+ 127.0.0.1:47365 +--------------------------+ +----------------+
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
- **Extension** (`extension/`): a Python add-in that registers the `RTD` function and returns
|
|
32
|
+
an `XVolatileResult`, Calc's mechanism for values that change on their own. Standard library
|
|
33
|
+
only, so it runs on the Python bundled with LibreOffice.
|
|
34
|
+
- **Bridge** (`src/calc_rtd_bridge/`): a separate process that creates the RTD server through
|
|
35
|
+
COM and drives it the way Excel does (`ServerStart`, `ConnectData`, `UpdateNotify`,
|
|
36
|
+
`RefreshData`, `Heartbeat`...). Keeping it outside LibreOffice means it can match the RTD
|
|
37
|
+
server's bitness (32/64-bit), and a misbehaving server cannot take the spreadsheet down.
|
|
38
|
+
|
|
39
|
+
## Install
|
|
40
|
+
|
|
41
|
+
Requirements: Windows and LibreOffice 4.0 or later.
|
|
42
|
+
|
|
43
|
+
1. Download the extension from the [Releases](https://github.com/andreydani/calc-rtd/releases)
|
|
44
|
+
page:
|
|
45
|
+
- `calc-rtd-win64.oxt` or `calc-rtd-win32.oxt` include the bridge as a standalone
|
|
46
|
+
program; nothing else to install. Pick the one that matches your RTD server (see below).
|
|
47
|
+
- `calc-rtd.oxt` contains no executable. It needs Python 3.9+ and
|
|
48
|
+
`pip install calc-rtd`; choose it if you prefer not to run a downloaded `.exe`.
|
|
49
|
+
2. In LibreOffice: **Tools > Extensions > Add**, select the file, then restart LibreOffice
|
|
50
|
+
(including the Quickstarter, if you use it).
|
|
51
|
+
|
|
52
|
+
> **32-bit or 64-bit?** An RTD server shipped as a DLL only loads into a process of the same
|
|
53
|
+
> bitness as the Excel it was installed for; that is the bridge you need (it does not have to
|
|
54
|
+
> match LibreOffice). If unsure, try `win64` first. Out-of-process (EXE) servers work with both.
|
|
55
|
+
|
|
56
|
+
> **The bundled program is not code-signed.** Windows SmartScreen or your antivirus may warn
|
|
57
|
+
> about it. It is built from this repository by GitHub Actions; use the Python-only extension
|
|
58
|
+
> if you would rather not run it.
|
|
59
|
+
|
|
60
|
+
> **Do not "Run as administrator".** Run LibreOffice (and the bridge) at the same privilege
|
|
61
|
+
> level as the application that feeds the RTD server. An elevated process cannot see the COM
|
|
62
|
+
> objects of a normal one, and the server fails with "Class not registered".
|
|
63
|
+
|
|
64
|
+
## Use
|
|
65
|
+
|
|
66
|
+
In Calc, type the formula as you would in Excel:
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
=RTD("Vendor.ProgID";;"ACME";"LAST")
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
The extension starts the bridge in the background the first time an `RTD` formula is
|
|
73
|
+
calculated, and the bridge exits about a minute after LibreOffice closes. Cells show `#N/A`
|
|
74
|
+
until the first value arrives, as in Excel; the very first start can take a few seconds. Server errors appear as text starting with
|
|
75
|
+
`#RTD:`, and `#RTD: bridge offline` means the bridge could not be started or reached.
|
|
76
|
+
|
|
77
|
+
Excel writes the function as `_xlfn.RTD` on the clipboard, and that spelling is accepted too.
|
|
78
|
+
If cells copied from Excel still show `#NAME?`, Calc kept them as unparsed text: use
|
|
79
|
+
**Edit > Find & Replace**, search for `_xlfn.` and replace it with nothing ("Search in:
|
|
80
|
+
Formulas"), which makes Calc read the formulas again.
|
|
81
|
+
|
|
82
|
+
You can also run the bridge yourself, for example to see its log:
|
|
83
|
+
|
|
84
|
+
```bat
|
|
85
|
+
calc-rtd-bridge -v serve
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Environment variables, read by the extension and the bridge:
|
|
89
|
+
|
|
90
|
+
| Variable | Meaning |
|
|
91
|
+
|---|---|
|
|
92
|
+
| `CALC_RTD_PORT` | TCP port on 127.0.0.1 (default 47365) |
|
|
93
|
+
| `CALC_RTD_AUTOSTART=0` | the extension never starts the bridge |
|
|
94
|
+
| `CALC_RTD_BRIDGE_CMD` | command line the extension uses to start the bridge |
|
|
95
|
+
| `CALC_RTD_TOKEN_FILE` | location of the authentication token |
|
|
96
|
+
|
|
97
|
+
### Simulated source (any OS, no RTD server needed)
|
|
98
|
+
|
|
99
|
+
```
|
|
100
|
+
=RTD("calcrtd.sim";;"clock") current time, every second
|
|
101
|
+
=RTD("calcrtd.sim";;"counter";0.2) 1, 2, 3... every 0.2 s
|
|
102
|
+
=RTD("calcrtd.sim";;"random";10;20) random number between 10 and 20
|
|
103
|
+
=RTD("calcrtd.sim";;"walk";"ACME";38.5) random walk starting at 38.5
|
|
104
|
+
=RTD("calcrtd.sim";;"echo";"hello") fixed text
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Try an RTD server without LibreOffice
|
|
108
|
+
|
|
109
|
+
`monitor` loads an RTD server directly and prints what Calc would receive. Use it to check
|
|
110
|
+
that a given server works with the bridge:
|
|
111
|
+
|
|
112
|
+
```bat
|
|
113
|
+
calc-rtd-bridge monitor "=RTD(Vendor.ProgID;;ACME;LAST)" --seconds 30
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
The formula can be pasted from Excel (`,` or `;` separators, quotes optional). For several
|
|
117
|
+
formulas use `--file formulas.txt` (one per line) or `--progid X --topics A B`. Put `-v` before
|
|
118
|
+
`monitor` for detailed logging. The exit code is 0 if updates were received.
|
|
119
|
+
|
|
120
|
+
`calc-rtd-bridge watch ...` does the same through the socket of a running bridge.
|
|
121
|
+
|
|
122
|
+
## Known limitations
|
|
123
|
+
|
|
124
|
+
- **Windows only** for real servers: RTD is a COM technology.
|
|
125
|
+
- **Excel files:** Calc imports RTD formulas in `.xlsx` files as `#NAME?`; re-enter them
|
|
126
|
+
(see the Find & Replace tip above). Saving to `.xlsx` does not produce a formula Excel
|
|
127
|
+
understands. Use `.ods`.
|
|
128
|
+
- Some vendors tie their RTD server to their own Excel add-in (login, licensing) and may
|
|
129
|
+
refuse a host other than Excel. Your data vendor's terms of use still apply.
|
|
130
|
+
- Out-of-process RTD servers need the RTD interfaces registered for marshalling, which
|
|
131
|
+
installing Excel does.
|
|
132
|
+
- The bridge listens on `127.0.0.1` only and requires a random token stored in a file that
|
|
133
|
+
only your user account can read (`%APPDATA%\calc-rtd\token`). Programs running under your
|
|
134
|
+
own account can still read it; the token keeps other accounts on the machine out.
|
|
135
|
+
- Updates are delivered at most every `--throttle` milliseconds (default 500; Excel uses 2000).
|
|
136
|
+
|
|
137
|
+
## Development
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
pip install -e . pytest
|
|
141
|
+
pytest # bridge, protocol, RTD host with a fake driver
|
|
142
|
+
python tools/build_oxt.py # builds dist/calc-rtd.oxt (no LibreOffice SDK needed)
|
|
143
|
+
unopkg add -f dist/calc-rtd.oxt
|
|
144
|
+
python tests/integration_libreoffice.py # end to end against a headless LibreOffice
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
To use the bridge from source instead of a release:
|
|
148
|
+
|
|
149
|
+
```bat
|
|
150
|
+
pip install git+https://github.com/andreydani/calc-rtd
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
`tools/build_oxt.py` writes the UNO type library (`.rdb`) directly in its binary format, so
|
|
154
|
+
`unoidl-write` from the SDK is not required. The protocol between extension and bridge is
|
|
155
|
+
documented in `src/calc_rtd_bridge/protocol.py`; any program can be a client of the bridge.
|
|
156
|
+
|
|
157
|
+
## License
|
|
158
|
+
|
|
159
|
+
MIT. Microsoft and Excel are trademarks of the Microsoft group of companies; LibreOffice is a
|
|
160
|
+
trademark of The Document Foundation.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "calc-rtd"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Use Excel RTD (RealTimeData) servers from LibreOffice Calc: the bridge that hosts the RTD server"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { text = "MIT" }
|
|
11
|
+
requires-python = ">=3.9"
|
|
12
|
+
dependencies = ["comtypes>=1.2; sys_platform == 'win32'"]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Programming Language :: Python :: 3",
|
|
15
|
+
"License :: OSI Approved :: MIT License",
|
|
16
|
+
"Operating System :: Microsoft :: Windows",
|
|
17
|
+
"Development Status :: 4 - Beta",
|
|
18
|
+
"Topic :: Office/Business :: Financial :: Spreadsheet",
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
[project.urls]
|
|
22
|
+
Homepage = "https://github.com/andreydani/calc-rtd"
|
|
23
|
+
Issues = "https://github.com/andreydani/calc-rtd/issues"
|
|
24
|
+
|
|
25
|
+
[project.scripts]
|
|
26
|
+
calc-rtd-bridge = "calc_rtd_bridge.cli:main"
|
|
27
|
+
|
|
28
|
+
[tool.setuptools.packages.find]
|
|
29
|
+
where = ["src"]
|
|
30
|
+
|
|
31
|
+
[tool.pytest.ini_options]
|
|
32
|
+
testpaths = ["tests"]
|
|
33
|
+
pythonpath = ["src"]
|
calc_rtd-0.1.0/setup.cfg
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: calc-rtd
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Use Excel RTD (RealTimeData) servers from LibreOffice Calc: the bridge that hosts the RTD server
|
|
5
|
+
License: MIT
|
|
6
|
+
Project-URL: Homepage, https://github.com/andreydani/calc-rtd
|
|
7
|
+
Project-URL: Issues, https://github.com/andreydani/calc-rtd/issues
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Topic :: Office/Business :: Financial :: Spreadsheet
|
|
13
|
+
Requires-Python: >=3.9
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Requires-Dist: comtypes>=1.2; sys_platform == "win32"
|
|
17
|
+
Dynamic: license-file
|
|
18
|
+
|
|
19
|
+
# calc-rtd
|
|
20
|
+
|
|
21
|
+
**Use Excel RTD (RealTimeData) servers from LibreOffice Calc**, with the formula you already know:
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
=RTD("Vendor.ProgID";;"TOPIC1";"TOPIC2")
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Many market-data terminals and industrial tools publish live data to spreadsheets through an
|
|
28
|
+
*RTD server*, a COM component that Microsoft Excel loads for its `RTD()` function. LibreOffice
|
|
29
|
+
Calc has no such function. calc-rtd adds it: a Calc extension provides `RTD()`, and a small
|
|
30
|
+
Windows bridge loads the vendor's RTD server and plays Excel's part of the conversation.
|
|
31
|
+
|
|
32
|
+
> **Status: experimental (0.1).** Verified end to end on Windows with LibreOffice and a
|
|
33
|
+
> third-party .NET RTD server, and on Linux with the built-in simulated source.
|
|
34
|
+
|
|
35
|
+
calc-rtd is an independent project. It is not affiliated with or endorsed by Microsoft or
|
|
36
|
+
The Document Foundation. It contains no Microsoft code: it implements the client side of the
|
|
37
|
+
publicly documented `IRtdServer` interface.
|
|
38
|
+
|
|
39
|
+
## How it works
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
LibreOffice Calc bridge (Windows process) RTD server
|
|
43
|
+
+------------------+ local TCP +--------------------------+ COM +----------------+
|
|
44
|
+
| calc-rtd.oxt |<--------------->| calc-rtd-bridge serve |<----->| IRtdServer |
|
|
45
|
+
| =RTD(...) | JSON lines | acts as Excel would | | (vendor's own) |
|
|
46
|
+
+------------------+ 127.0.0.1:47365 +--------------------------+ +----------------+
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
- **Extension** (`extension/`): a Python add-in that registers the `RTD` function and returns
|
|
50
|
+
an `XVolatileResult`, Calc's mechanism for values that change on their own. Standard library
|
|
51
|
+
only, so it runs on the Python bundled with LibreOffice.
|
|
52
|
+
- **Bridge** (`src/calc_rtd_bridge/`): a separate process that creates the RTD server through
|
|
53
|
+
COM and drives it the way Excel does (`ServerStart`, `ConnectData`, `UpdateNotify`,
|
|
54
|
+
`RefreshData`, `Heartbeat`...). Keeping it outside LibreOffice means it can match the RTD
|
|
55
|
+
server's bitness (32/64-bit), and a misbehaving server cannot take the spreadsheet down.
|
|
56
|
+
|
|
57
|
+
## Install
|
|
58
|
+
|
|
59
|
+
Requirements: Windows and LibreOffice 4.0 or later.
|
|
60
|
+
|
|
61
|
+
1. Download the extension from the [Releases](https://github.com/andreydani/calc-rtd/releases)
|
|
62
|
+
page:
|
|
63
|
+
- `calc-rtd-win64.oxt` or `calc-rtd-win32.oxt` include the bridge as a standalone
|
|
64
|
+
program; nothing else to install. Pick the one that matches your RTD server (see below).
|
|
65
|
+
- `calc-rtd.oxt` contains no executable. It needs Python 3.9+ and
|
|
66
|
+
`pip install calc-rtd`; choose it if you prefer not to run a downloaded `.exe`.
|
|
67
|
+
2. In LibreOffice: **Tools > Extensions > Add**, select the file, then restart LibreOffice
|
|
68
|
+
(including the Quickstarter, if you use it).
|
|
69
|
+
|
|
70
|
+
> **32-bit or 64-bit?** An RTD server shipped as a DLL only loads into a process of the same
|
|
71
|
+
> bitness as the Excel it was installed for; that is the bridge you need (it does not have to
|
|
72
|
+
> match LibreOffice). If unsure, try `win64` first. Out-of-process (EXE) servers work with both.
|
|
73
|
+
|
|
74
|
+
> **The bundled program is not code-signed.** Windows SmartScreen or your antivirus may warn
|
|
75
|
+
> about it. It is built from this repository by GitHub Actions; use the Python-only extension
|
|
76
|
+
> if you would rather not run it.
|
|
77
|
+
|
|
78
|
+
> **Do not "Run as administrator".** Run LibreOffice (and the bridge) at the same privilege
|
|
79
|
+
> level as the application that feeds the RTD server. An elevated process cannot see the COM
|
|
80
|
+
> objects of a normal one, and the server fails with "Class not registered".
|
|
81
|
+
|
|
82
|
+
## Use
|
|
83
|
+
|
|
84
|
+
In Calc, type the formula as you would in Excel:
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
=RTD("Vendor.ProgID";;"ACME";"LAST")
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
The extension starts the bridge in the background the first time an `RTD` formula is
|
|
91
|
+
calculated, and the bridge exits about a minute after LibreOffice closes. Cells show `#N/A`
|
|
92
|
+
until the first value arrives, as in Excel; the very first start can take a few seconds. Server errors appear as text starting with
|
|
93
|
+
`#RTD:`, and `#RTD: bridge offline` means the bridge could not be started or reached.
|
|
94
|
+
|
|
95
|
+
Excel writes the function as `_xlfn.RTD` on the clipboard, and that spelling is accepted too.
|
|
96
|
+
If cells copied from Excel still show `#NAME?`, Calc kept them as unparsed text: use
|
|
97
|
+
**Edit > Find & Replace**, search for `_xlfn.` and replace it with nothing ("Search in:
|
|
98
|
+
Formulas"), which makes Calc read the formulas again.
|
|
99
|
+
|
|
100
|
+
You can also run the bridge yourself, for example to see its log:
|
|
101
|
+
|
|
102
|
+
```bat
|
|
103
|
+
calc-rtd-bridge -v serve
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Environment variables, read by the extension and the bridge:
|
|
107
|
+
|
|
108
|
+
| Variable | Meaning |
|
|
109
|
+
|---|---|
|
|
110
|
+
| `CALC_RTD_PORT` | TCP port on 127.0.0.1 (default 47365) |
|
|
111
|
+
| `CALC_RTD_AUTOSTART=0` | the extension never starts the bridge |
|
|
112
|
+
| `CALC_RTD_BRIDGE_CMD` | command line the extension uses to start the bridge |
|
|
113
|
+
| `CALC_RTD_TOKEN_FILE` | location of the authentication token |
|
|
114
|
+
|
|
115
|
+
### Simulated source (any OS, no RTD server needed)
|
|
116
|
+
|
|
117
|
+
```
|
|
118
|
+
=RTD("calcrtd.sim";;"clock") current time, every second
|
|
119
|
+
=RTD("calcrtd.sim";;"counter";0.2) 1, 2, 3... every 0.2 s
|
|
120
|
+
=RTD("calcrtd.sim";;"random";10;20) random number between 10 and 20
|
|
121
|
+
=RTD("calcrtd.sim";;"walk";"ACME";38.5) random walk starting at 38.5
|
|
122
|
+
=RTD("calcrtd.sim";;"echo";"hello") fixed text
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Try an RTD server without LibreOffice
|
|
126
|
+
|
|
127
|
+
`monitor` loads an RTD server directly and prints what Calc would receive. Use it to check
|
|
128
|
+
that a given server works with the bridge:
|
|
129
|
+
|
|
130
|
+
```bat
|
|
131
|
+
calc-rtd-bridge monitor "=RTD(Vendor.ProgID;;ACME;LAST)" --seconds 30
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
The formula can be pasted from Excel (`,` or `;` separators, quotes optional). For several
|
|
135
|
+
formulas use `--file formulas.txt` (one per line) or `--progid X --topics A B`. Put `-v` before
|
|
136
|
+
`monitor` for detailed logging. The exit code is 0 if updates were received.
|
|
137
|
+
|
|
138
|
+
`calc-rtd-bridge watch ...` does the same through the socket of a running bridge.
|
|
139
|
+
|
|
140
|
+
## Known limitations
|
|
141
|
+
|
|
142
|
+
- **Windows only** for real servers: RTD is a COM technology.
|
|
143
|
+
- **Excel files:** Calc imports RTD formulas in `.xlsx` files as `#NAME?`; re-enter them
|
|
144
|
+
(see the Find & Replace tip above). Saving to `.xlsx` does not produce a formula Excel
|
|
145
|
+
understands. Use `.ods`.
|
|
146
|
+
- Some vendors tie their RTD server to their own Excel add-in (login, licensing) and may
|
|
147
|
+
refuse a host other than Excel. Your data vendor's terms of use still apply.
|
|
148
|
+
- Out-of-process RTD servers need the RTD interfaces registered for marshalling, which
|
|
149
|
+
installing Excel does.
|
|
150
|
+
- The bridge listens on `127.0.0.1` only and requires a random token stored in a file that
|
|
151
|
+
only your user account can read (`%APPDATA%\calc-rtd\token`). Programs running under your
|
|
152
|
+
own account can still read it; the token keeps other accounts on the machine out.
|
|
153
|
+
- Updates are delivered at most every `--throttle` milliseconds (default 500; Excel uses 2000).
|
|
154
|
+
|
|
155
|
+
## Development
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
pip install -e . pytest
|
|
159
|
+
pytest # bridge, protocol, RTD host with a fake driver
|
|
160
|
+
python tools/build_oxt.py # builds dist/calc-rtd.oxt (no LibreOffice SDK needed)
|
|
161
|
+
unopkg add -f dist/calc-rtd.oxt
|
|
162
|
+
python tests/integration_libreoffice.py # end to end against a headless LibreOffice
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
To use the bridge from source instead of a release:
|
|
166
|
+
|
|
167
|
+
```bat
|
|
168
|
+
pip install git+https://github.com/andreydani/calc-rtd
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
`tools/build_oxt.py` writes the UNO type library (`.rdb`) directly in its binary format, so
|
|
172
|
+
`unoidl-write` from the SDK is not required. The protocol between extension and bridge is
|
|
173
|
+
documented in `src/calc_rtd_bridge/protocol.py`; any program can be a client of the bridge.
|
|
174
|
+
|
|
175
|
+
## License
|
|
176
|
+
|
|
177
|
+
MIT. Microsoft and Excel are trademarks of the Microsoft group of companies; LibreOffice is a
|
|
178
|
+
trademark of The Document Foundation.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
src/calc_rtd.egg-info/PKG-INFO
|
|
5
|
+
src/calc_rtd.egg-info/SOURCES.txt
|
|
6
|
+
src/calc_rtd.egg-info/dependency_links.txt
|
|
7
|
+
src/calc_rtd.egg-info/entry_points.txt
|
|
8
|
+
src/calc_rtd.egg-info/requires.txt
|
|
9
|
+
src/calc_rtd.egg-info/top_level.txt
|
|
10
|
+
src/calc_rtd_bridge/__init__.py
|
|
11
|
+
src/calc_rtd_bridge/__main__.py
|
|
12
|
+
src/calc_rtd_bridge/cli.py
|
|
13
|
+
src/calc_rtd_bridge/client.py
|
|
14
|
+
src/calc_rtd_bridge/com_driver.py
|
|
15
|
+
src/calc_rtd_bridge/core.py
|
|
16
|
+
src/calc_rtd_bridge/protocol.py
|
|
17
|
+
src/calc_rtd_bridge/rtd_host.py
|
|
18
|
+
src/calc_rtd_bridge/server.py
|
|
19
|
+
src/calc_rtd_bridge/sim.py
|
|
20
|
+
tests/test_bridge.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
calc_rtd_bridge
|