unoconv将.xlsx文件导出为像png的图像
我在我的64位Ubuntu 14.04上成功安装了unoconv
。
我想把一个.xlsx文件的第一张表导出成图片,比如png或jpg格式。
我试过这个:
unoconv -l & 9998 ## this is to start the python listener
unoconv -f png abc.xlsx
但是我得到了以下结果:
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 })
我该怎么办呢?
3 个回答
0
是的,把xlsx文件转换成html格式会出现这个错误。但是把xlsx文件转换成pdf格式就不会。
0
我在使用Ubuntu 12.x服务器时有点不顺利。这个系统自带了LibreOffice。我尝试通过OpenOffice网站的Debian安装程序来安装OpenOffice,但它无法转换任何类型的文件。
于是我通过执行以下命令把所有东西都删除了。
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
然后我添加了LibreOffice的仓库。
sudo add-apt-repository ppa:libreoffice/libreoffice-4-2
sudo apt-get update
sudo apt-get dist-upgrade
接着我安装了LibreOffice和unoconv(因为apt-get版本无法运行,所以我用了git clone)。
sudo apt-get install libreoffice
git clone https://github.com/dagwieers/unoconv
cd unoconv && sudo make install
这些步骤解决了我的问题,但我仍然无法将docx或xlsx文件转换成图片 :(不过从xlsx转换成pdf再转换成图片是可以的。
2
这看起来是Unoconv里的一个不太好的bug。与此同时,我好像找到了一种解决办法:
unoconv Test_Data.xlsx # converts to PDF by default
unoconv -f png Test_Data.pdf # *then* converts to PNG
根据我快速搜索的结果,这个问题可能和LibreOffice或者Python的版本有关。如果我的解决办法对你不管用,试着换换版本也是个不错的选择。