Save calc document as CSV with Python macro

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
strongleg
Posts: 10
Joined: Sat Oct 28, 2017 4:41 pm

Save calc document as CSV with Python macro

Post by strongleg »

 Edit: Split from [Solved] Save calc document like csv file by macro since that topic is for Basic, is marked solved, and the question is from a different person 
that's great, but how to write it in python?
OpenOffice 2.4 on Ubuntu 9.04
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: [Solved] Save calc document like csv file by macro

Post by Villeroy »

strongleg wrote:that's great, but how to write it in python?
You simply write the same statements in your preferred langauge.
In Python:

Code: Select all

ThisComponent = XSCRIPTCONTEXT.getDocument()
StarDesktop = uno.getComponentContext().ServiceManager.createInstance('com.sun.star.frame.Desktop')
The rest is the same in Python syntax.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
karolus
Volunteer
Posts: 1160
Joined: Sat Jul 02, 2011 9:47 am

Re: [Solved] Save calc document like csv file by macro

Post by karolus »

hallo
At least for Libreoffice:

Code: Select all

BASIC       <|>   Python
StarDesktop  ==   XSCRIPTCONTEXT.getDesktop() 
AOO4, Libreoffice 6.1 on Rasbian OS (on ARM)
Libreoffice 7.4 on Debian 12 (Bookworm) (on RaspberryPI4)
Libreoffice 7.6 flatpak on Debian 12 (Bookworm) (on RaspberryPI4)
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: [Solved] Save calc document like csv file by macro

Post by Villeroy »

karolus wrote:hallo
At least for Libreoffice:

Code: Select all

BASIC       <|>   Python
StarDesktop  ==   XSCRIPTCONTEXT.getDesktop()  
I did not know. :ouch:
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
karolus
Volunteer
Posts: 1160
Joined: Sat Jul 02, 2011 9:47 am

Re: [Solved] Save calc document like csv file by macro

Post by karolus »

Villeroy wrote:
karolus wrote:hallo
At least for Libreoffice:

Code: Select all

BASIC       <|>   Python
StarDesktop  ==   XSCRIPTCONTEXT.getDesktop()
I did not know. :ouch:
I also noticed this only one or two weeks ago
AOO4, Libreoffice 6.1 on Rasbian OS (on ARM)
Libreoffice 7.4 on Debian 12 (Bookworm) (on RaspberryPI4)
Libreoffice 7.6 flatpak on Debian 12 (Bookworm) (on RaspberryPI4)
Post Reply