OOSheet is a Python module for manipulating LibreOffice spreadsheet documents and creating macros.
Using Python, you interact with an LibreOffice instance to develop and test your code. When you’re finished you can insert your python script inside the document to run it as macro, if this is what you desire.
OOSheet API was inspired by JQuery. It uses selectors in same way that you would use in LibreOffice, with cascading method calls for quick development. Part of the API was also inspired by Django’s object-relational mapper.
When you use a lot of spreadsheets and have some programming skills, writing scripts to make your life easier are something that will come to your mind. If you start to look for your options with LibreOffice, you’ll see that OO.org Basic is ugly and weird, while Python support is powerful but very tricky. And finally, your routines are likely to be coupled to the structure of your spreadsheet, so the best place to have your macros would be inside your documents, but OO.org provides no way for you to do that.
If you see yourself in need of automating routines in a spreadsheet and like Python, OOSheet is surely for you.
If your situation is not really like this but you’re considering using PyUno for anything, it’s very likely that you’ll find OOSheet useful in some way, even if your document is not a spreadsheet. The base class OODoc may be a good general wrapper for PyUno, and OOPacker class can be used to insert your python script in any OO.org document.
For using OOSheet you need a running instance of LibreOffice. If you just want to generate a document, for example, as a result of a web system in which user will download some automatically generated spreadsheet, then this module is probably not what you’re looking for. It could be used though, if you’re willing to manage a running LibreOffice process.
Download / Install¶
$ pip3 install oosheet
You can get the pip command here.
You’ll need git and python uno. If you use a Debian-based GNU/Linux distribution (like Ubuntu), you can do this with:
$ sudo aptitude install python3-uno
OOSheet was developed and tested on Python 3.5 and LibreOffice 5.1. It should work in other versions, though. If you try it in other environments, please report results to author.
The OOSheet source can be downloaded as a tar.gz file from http://pypi.python.org/pypi/oosheet
OOSheet is free and open for usage under the MIT license.
- Using OOSheet
- OOSheet with Spreadsheets
- Working with documents types other than spreadsheet
- Python Macros
Please submit bugs and patches, preferably with tests. All contributors will be acknowledged. Thanks!
OOSheet was created by Luis Fagundes and was sponsored by hacklab/ until version 1.2.
Fudge project also take credits for a good documentation structure, on which this one was based.
Oscar Garcia suggested the user selection feature, implemented in v0.9.4.
Thomas Lundqvist sent implementation of data_array property, implemented in v0.9.6.
Luc Jean sent patch that allows OOSheet to run on Windows Vista with default Python interpreter, v0.9.7
- Works with Python 3 and LibreOffice 5
- Probably better support for Windows
- Removed dynamic column constant (ex: from oosheet.colums import C)
- Move OOSheet.Quit() to OODoc.quit()
- Correct bug in OOPacker.script_name() for Windows 7
- Change fetching InstallPath winreg key for LibreOffice 3.4 on Windows 7
- Much better performance when acessing via sockets
- [NEW] Objects can be accessed as arrays
- [NEW] oosheet-launch reminds that complicated launching command line
- [NEW] support for LibreOffice
- [NEW] find() methods searches selection for matching cells
- [NEW] Iterators for cells, rows and columns
- [MOD] Refactor for working with all types of documents
- [FIX] works with default Python interpreter in Windows Vista
- [NEW] data_array property returns selection’s values as 2d-tuple
- [FIX] flatten() breaking fields with formulas based on zero values formatted as strings (ex: R$ 0,00)
- [NEW] S() now gets user’s selection
- [FIX] Date format is not automatically set if current format is already a date
- Fixes packaging problem
- [NEW] flatten() method
- [NEW] sheet and cell protection
- [NEW] grow_DIRECTION_until and shrink_DIRECTION_until methods
- [NEW] last_row, last_column, first_row, first_column properties
- [FIX] api documentation error in shift_until()
- [FIX] __repr__ of empty selector raised error
- Documentation changed to include installation instructions with pip and link to website
- Code is same as 0.9.0
- first release