erworker.blogg.se

Libreoffice base python
Libreoffice base python







libreoffice base python libreoffice base python

To do that we use the method getCurrentSelection() of the object ‘model’ that we defined in the context() method further up. This is the easiest part, simply: # call function context() Check out my Annex1 to learn how to do it quickly.

  • print in the console and in a cell (optional)īut first, to make testing easier I advise to bind our main() function to a combination of keys on your keyboard.
  • These objects were briefly explained in part 2 of these series of tutorials. This will allow us to access these objects from other functions, like out main() function. In this ‘context()’ method, we first declare the 3 useful variables that will hold our objects as Global Variables. You can either define these variables at the global level of your program or like I like to do, in a separate function that I call context() to make it more customizable in later programs. This XSCRIPTCONTEXT is a UNO object that gather all you need to manipulate LibreOffice Documents with Python scripts.

    libreoffice base python

    Please refer to my previous tutorials for creating a program and using the APSO console.įirst you need to define the variables provided by XSCRIPTCONTEXT. We’ll see how to manage them in a later post.Ī good way to illustrate the 4 different cell types is to play with them with a simple python code that will display in the console the type of cell selected in LibreOffice Calc.

  • formula is the type of any LibreOffice Calc cell that contain a formula.ĭates, currencies, decimals, booleans within LibreOffice are not types but different formats of numbers.
  • string is the type of any text content of a LibreOffice Calc cell.
  • value is the type of any numerical content of a LibreOffice Calc cell.
  • empty is simply the type of an empty LibreOffice Calc cell.
  • These types names are quite self-explanatory: Its type comes from its content and can only be one of the 4 following types: In this episode of my LibreOffice Calc & Python Programming tutorial series I am going to talk about the different types of data stored in a LibreOffice cell, and what type to use in the Python code to keep the same data type than in LibreOffice.Ī cell within a LibreOffice Table has no predefined type.









    Libreoffice base python