Simple extension for LibreOffice for importing iCalendar files (.ics) into LibreOffice Calc.
Based on a tutorial by Andreas Mantke and his template
Another nice example can be found here.
As introduction for scripting LibreOffice with Python see these sources:
- Designing & Developing Python Applications
- OpenOffice Developer Guide: Extensions
- Transfer from Basic to Python
- Interface-oriented programming in OpenOffice / LibreOffice: automate your office tasks with Python Macros
- Debugging Python components in LibreOffice
Before the extension can be packaged, all translations have to be compiled as .mo files to be used by gettext:
make compile-translations
To build a LibreOffice extension use the Makefile that is provided with the project:
make zip
To install the extension in LibreOffice execute the following command:
make install
The file src/ical2csv_gui.py and src/ical2csv.py contain a CLI and a GUI application to convert iCalendar files into CSV files.
To create a single EXE file for Windows user, a pyinstaller .spec file has to be created:
pyinstaller --onefile --windowed -i images/icon.ico --add-data C:\Users\christian\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\ics\grammar\contentline.ebnf;ics\grammar\ src\ical2csv_gui.py
Alternativly, you can use the provided spec file in the repo:
pyinstaller ical2csv_gui.spec
- Download LibreOffice extension: https://github.com/prometheus42/libreoffice-ical-importer/releases/tag/v0.2
- Install extension in LibreOffice
- Open LibreOffice Calc
- Click on the tools ("Werkzeuge") menu and start the import function
- Choose iCal file
The fields of the iCal file should be stored as columns in the table.
By default, there is no default stdout on Windows. All output from the extension will just vanish. To get a console to be used as stdout, you can start LibreOffice using soffice.com instead of soffice.exe as described in the documentation:
start "C:\Program Files\LibreOffice\program\soffice.com"
All debug messages will also be written to log file:
- /home/<username>/.config/libreoffice/4/user/ (Linux)
- C:\Users\<username>\AppData\Roaming\LibreOffice\4\user\ (Windows)
- META-INF/manifest.xml -> manifest declaring all parts of the extension
- description.xml -> XML file with all information about the extension
- gui.xcu -> XML file for all GUI elements of the extension
- src/import_ical.py -> python code to read iCalendar file and write data into worksheet
- registration/license_*.txt -> license files in various languages
- description/description_*.txt -> info text for extension in various languages
- images/icon.png -> icon for extension
- extensionname.txt -> contains the name of the extension for build script
- build.py -> python script to build .oxt file
- Icon for IcalImporter from GNOME Desktop Tango icon set. Licensed under GNU General Public License version 2.
This extension is released under the MIT License.
IcalImporter runs under Python 3.6 and newer. Currently (March 2025) LibreOffice seems to ship with Python 3.10.
The following Python packages are necessary:
- click: Composable command line interface toolkit licensed under the BSD License.
- Ics.py: iCalendar for Humans, licensed under the Apache 2.0 License.
- Arrow: Better dates & times for Python, licensed under the Apache 2.0 License.
- dateutil as dependency of Arrow, licensed under the Apache License and BSD License.
- tatsu as dependency of ics, licensed under a BSD-style License.
- six as dependency of ics, licensed under the MIT License.