Home » excel » python – unoconv export .xlsx file into image like png

python – unoconv export .xlsx file into image like png

Posted by: admin April 23, 2020 Leave a comment

Questions:

I have successfully installed unoconv in my ubuntu 14.04 64 bit.

I want to export the first sheet of an .xlsx file into image like png or jpg.

I tried

unoconv -l & 9998 ## this is to start the python listener
unoconv -f png abc.xlsx

I get the following:

unoconv: UnoException during export phase:
Unable to store document to file:///var/virtual/abc.png (ErrCode 3088)

Properties: ((com.sun.star.beans.PropertyValue){ Name = (string)"FilterName", Handle = (long)0x0, Value = (any){ (string)"draw_png_Export" }, State = (com.sun.star.beans.PropertyState)DIRECT_VALUE }, (com.sun.star.beans.PropertyValue){ Name = (string)"Overwrite", Handle = (long)0x0, Value = (any){ (boolean)true }, State = (com.sun.star.beans.PropertyState)DIRECT_VALUE }, (com.sun.star.beans.PropertyValue){ Name = (string)"OutputStream", Handle = (long)0x0, Value = (any){ (com.sun.star.uno.XInterface)0x2695ef8{, supportedInterfaces={com.sun.star.io.XOutputStream,com.sun.star.lang.XTypeProvider}} }, State = (com.sun.star.beans.PropertyState)DIRECT_VALUE })

What should I do?

How to&Answers:

This seems to be an unfortunate bug in Unoconv. In the meantime, I seem to have found a workaround:

unoconv Test_Data.xlsx # converts to PDF by default
unoconv -f png Test_Data.pdf # *then* converts to PNG

From what I can tell from a quick Google search, this seems to be an issue with either LibreOffice or Python versions. If my workaround isn’t viable for you, it’s worth a try playing around with versions.

Answer:

I was little bit unfortunate while using Ubunutu 12.x server. It has builtin libreoffice. I tried to install openoffice through debian installer from open office site. But it wasn’t able to convert any type of file.

So I removed everything by executing following commands.

sudo apt-get remove --purge libreoffice* libexttextcat-data* && sudo apt-get autoremove
sudo apt-get purge openoffice*.* && sudo apt-get autoremove
sudo apt-get remove --purge unoconv

Then Add libreoffice repository

sudo add-apt-repository ppa:libreoffice/libreoffice-4-2
sudo apt-get update
sudo apt-get dist-upgrade

Then install libreoffice and unoconv (apt-get version wasn’t executing so I used git clone)

sudo apt-get install libreoffice
git clone https://github.com/dagwieers/unoconv
cd unoconv && sudo make install

These steps resolve my issues but I am still not able to convert docx or and xlsx to image :(. Where as from xlsx to pdf to image is working.

Answer:

Yes. Convert xlsx to html triggers this error. But xlsx to pdf doesn’t