Python module to generate Libreoffice documents (ODT and ODS) programatically.
Morever, you can export them to (.xlsx, .docx, .pdf) easyly.
It uses Libreoffice uno module, so you need Libreoffice to be installed in your system.
Only Linux is supported. I'm going to write unogenerator installation methods for some main Linux Distributions
This is a Hello World example. You get the example in odt, docx and pdf formats:
First you have to launch libreoffice as a service. Run unogenerator_start
.
from unogenerator import ODT_Standard
with ODT_Standard() as doc:
doc.addParagraph("Hello World", "Heading 1")
doc.addParagraph("Easy, isn't it","Standard")
doc.save("hello_world.odt")
doc.export_docx("hello_world.docx")
doc.export_pdf("hello_world.pdf")
This is a Hello World example. You'll get example files in ods, xlsx and pdf formats:
You don't have to relaunch unogenerator_start
if you did before
from unogenerator import ODS_Standard
with ODS_Standard() as doc:
doc.addCellMergedWithStyle("A1:E1", "Hello world", style="BoldCenter")
doc.save("hello_world.ods")
doc.export_xlsx("hello_world.xlsx")
doc.export_pdf("hello_world.pdf")
Python unogenerator package has the following scripts:
Launch libreoffice server, as many process as cpus in your computer.
Stops libreoffice server instances
Monitors your libreoffice server instances
With this tool you can translate several odt files with one command. It generates .pot and .po files, where you can set your translations. Then run your command again and you'll get your files translated
unogenerator_translation --from_language es --to_language en --input original.odt --input original2.odt --output_directory "translation_original"
You can use --fake to see simulation of your translation
With this tool you can generate a demo
With this tool you can generate a demo with a lot of files to benchmark your unogenerator serve
You can read documentation in doc directory. It has been created with unogenerator.
- Removed statistics to improve speeds
- Added new exceptions: CoordException, RangeException
- Improve localc1989 methods and documentation
- Removed all reusing references
- Added method can_import_uno to allow programs to detect and ignore errors importing uno
- Fixed bug with addListOfRows with empty lor. Removed innecesary reusing files
- Fixed bug with addRow with empty row
- Unogenerator now uses pydicts-0.8.0. Old casts and datetime_functions removed
- Improved test coverage to 81%
- pydicts module is now used for list of dictionaries methods
- Added new methods to add values without styles. They are used to edit styled templates files. New methods: addCell, addCellMerged, addRow, addColumn, addListOfRows, addListOfColumns
- Improved get_values speed
- Optimize addRowWithStyle addColumnWithStyle and addListOfRowsWithStyle.
- Removed cellbycell parameter from this methods.
- Added ODT method to insert a HTML block
- Fixed bug deleting default sheet
- Migrated to poetry installation method
- Added method is_server_working()
- [unogenerator_monitor] Added --recommended parameter to set max recmmended memory in Mb. 600Mb per cpu by default.
- Replaced pkg_resources module by importlib.resources as recommended in python.org
- Added helper 'helper_split_big_listofrows' to automatically split a sheet in several ones, when is number or rows is bigger than a max_rows parameter
- Fixed bug with image size detection.
- Helper_totals_by_range now hides total of totals by default.
- ODS.export_pdf now uses one pdf page per sheet by default.
- Added ODS.setSheetStyle. If you use ODS_Standard you can use the portrait style.
- ODT images size can be managed automatically.
- Now you can trim images to remove innecesary space.
- Range.start refactorized to Range.c_start. Range.end refactorized to Range.c_end.
- Added getBlockValuesByRange and getBlockValuesByRangeWithCast, to get values from sheet very fast
- Added a sleep time launch libreoffice instances to try to avoid some issues.
- unogenerator_start detects if LibreOffice instances are already launched.
- Added ODT.addStringHyperlinks method to create hyperlinks in ODT documents.
- unogenerator_translator. Removed --translate parameter. Now is implicit.
- unogenerator_translator. Hyperlink strings are now translated and url preserved.
- unogenerator_translator. ODT metadata are now translated.
- ODT.addListOfRows bug fixed when rows were 0.
- Standard style is now default paragraph in ODT.
- unogenerator_translator. Entries in po files are now sorted by comment.
- Now you can use with statement with ODF classes.
- Added Coord, Range, ColorsNamed to unogenerator import.
- Added skip_up and skip_down parameters to getvalues().
- addListOfRows and addListOfColumns now returns created range.
- Added VerticalBoldCenter style to standard.ods template
- Improved installation methods documentation at INSTALL.md
- Fix bug with missing keys parameter
- Improved log and debug system.
- ODS.addListOfRowsWithStyle is now almost instant with lots of cells.
- helper_list_of_ordereddicts now uses ODS.addListOfRowsWithStyle to improve doc generation.
- Fixed error when percentage value is None.
- Fixed problem translating demo documents.
- ODS.addCell is now used to change values or strings, but doesn't change defined property styles, if they aren't defined
- Increased max attempts to reconnect to libreoffice instances.
- Added feature to insert images from bytes sequence
- Fixed bugs with old methods for numrows and numcolumns
- Improved get methods. Added detailed output.
- Added styles: Center, Right, VerticalCenter to standard.ods
- Added a helper to create a ods sheet with all internal style names.
- Added statistics module. Added a method to create an internal statistics ods sheet.
- Added all needed dependencies (tqdm, colorama, polib, psutil) to setup.py
- Added --pdf argument to
unogenerator_translation
to return translation in a pdf file too. - If there's a problem getting unogenerator instances process information, it retries 10 attempts by default.
- Added
unogenerator_translation
script to translate odf files using .po files. - Added sortRange method.
- Added findall_and_replace method.
- Changed vms to rss in psutil to get memory info.
- Auto remove default sheet feature enabled.
- Added find method.
- Added used cpu in monitor info.
- Added method find_and_delete_until_the_end_of_document.
- Added monitor to restart server when needed.
- Find and Replace method improved.
- Automatically creates directories to save or export files.
- Added statistics and timing withd --debug DEBUG.
- Process migrate to other port if there's a problem creating it.
- Page breaks improved.
- Tables improved.
- Added method LoadStylesFromFile.
- Added deleteAll method to delete all document content.
- Added method helper_list_of_ordereddicts_with_totals.
- Concurrent demo has new parameter loops to increment script load.
- Added --backtrace in
unogenerator_start
to try to log something (Experimental) - Save and export methods use now temporal directories to avoid locks
- Added method helper_totals_from_range,
- Added str method to Coord and Range to write code faster without .string()
- Added dispatcher and create service methods.
- Added posibility to link images to document.
- Image width and height are now in cm units.
- Added method addCellNames() for ranged names.
- Improving freezeAndSelect with None values.
- Added range column and number copy additions.
- Replaced server.sh by
unogenerator_start
andunogenerator_stop
- Added helper_list_of_dict and helper_list_of_ordereddict methods
- Changed vertical alignment to center in all personal styles
- Removed Gentoo confd initd files. Moved to unogenerator_daemon in myportage
- server.sh now launches n instances
- Code works with concurrency. Added method to change to next_port
- Added .conf and init.d for Gentoo
- Date and times formats are showed correctly in Calc
- Helpers added
- Added init.d daemon to launch server
- Improving helpers and ods methods
- Added basic features