Amourspirit / python_libre_pythonista_ext

Apache License 2.0
100 stars 6 forks source link

logo

LibrePythonista

License

LibrePythonista is an extension for LibreOffice Calc. The extension allows Interactive Python code to be run directly in a spreadsheet. LibrePythonista has its own PIP package manager to install additional Python packages.

LibrePythonista is currently in beta and is subject to change based on feedback.

LibrePythonista is free and open source software so there are no fees to start using it.

LibrePythonista bring the power of Pandas, Matplotlib and much more to LibreOffice Calc.

All python code is executes on your local computer. This can alleviate many concerns around data privacy as your data

Using LibrePythonista is it possible to create Data frame's, Series, custom Graphs an much more directly in a spreadsheet.

LibrePythonista is built using OOO Development Tools which removes many barriers when working with the LibreOffice API.

What is LibrePythonista?

Intro

LibrePythonista brings the power of Python analytics into LibreOffice Calc. Use it to process data in Calc with Python code. You type Python directly into a cell via the code edit window, the Python calculations runs locally, and your results are displayed in the sheet.

500

LibrePythonista comes with a core set of Python libraries. Use Python libraries to simplify your data analysis, find patterns and hidden insights, and visualize your data with plots.

Features

LibrePythonista is a powerful tool for data analysis and visualization in LibreOffice Calc. It allows you to:

Watch the Introduction Video

Watch the Introduction Video

Start using Python

To begin using LibrePythonista, select a cell and on the LibrePy menu, Insert Python. This tells Calc that you want to write a Python formula in the selected cell.

menu_001

Alternatively insert using shortcut Shift+Ctl+Alt+L or by clicking on the toolbar button.

toolbar_py_c

LibrePythonista uses the custom Python function lp() to interface between Calc and Python. The lp() function accepts Calc objects like ranges, named ranges, and data ranges. You can also directly type references into a Python cell with the lp() function. For example, to reference cell A1 use lp("A1") and for the range B1:C5 use lp("B1:C5"). For a named range with headers named MyRange, use lp("MyRange", headers=True).

If the range or named range has empty rows at the end of the range then collapse=True can be used. The collapse parameter instructs the Data frame to exclude empty rows at the end of the named range. This way when new data is added to the end of the range the Data frame will automatically recalculate to include the new rows.

Example named df = lp("A2:D81", headers=True, collapse=True)

The following image shows a Python in Calc calculation adding the values of cell A1 and B1, with the Python result returned in cell C1.

image

Code Editing

When a cell contains Python code It can be edit by clicking the control and choosing Edit Code.

Experimental Code Editor

As of version 0.6.0, the code editor has been updated to include syntax highlighting and code completion. Currently the code editor is experimental.

To activated the experimental code editor, open the LibreOffice Extension Manager and click on the LibrePythonista extension. Then click on the Options button. Navigate to LibrePythonista -> Options check the box for Use Experimental Python Cell Editor and click OK. Now restart LibreOffice to activate the new code editor.

image

Default Code Editor

image

Or Python cells and charts can right click and choose Pythonista --> Edit Code image

Image for the code editor for the example above. tri_code

Security

LibrePythonista is designed to run Python code locally on your computer. This means that your data never leaves your computer. LibrePythonista does not send your data to any external servers. LibrePythonista is open source software and the code is available on GitHub.

Running Sheet Level Python

LibrePythonista allows Python code to be run at the sheet level. This means that Python code can be run in any cell in the sheet. This can be a security risk if the sheet is from a untrusted source. To mitigate this risk, LibrePythonista will not run Python code unless macros have been enabled for the sheet. This means that the user must enable macros for the sheet before Python code can be run.

Usually, when a sheet is opened, LibreOffice will ask the user if they want to enable macros. If the user does not enable macros, then Python code will not run. If the user enables macros, then Python code will run.

The recommended security setting for LibrePythonista is Medium. This setting will allow Python code to run when macros are enabled. To set the security level, go to Tools -> Options -> LibreOffice -> Security -> Macro Security and set the security level to Medium.

Other Resources