Python将Excel文件(xls或xlsx)转换为/从ODS

时间:2022-04-09 14:03:02

I've been scouring the net to find a Python library or tool that can converts an Excel file to/from ODS format, but haven't been able to come across anything.

我一直在网上搜寻可以将Excel文件转换成或转换成ODS格式的Python库或工具,但一直没有找到。

I need the ability to input and output data in either format. We don't need to worry about merged cells, formulas or anything non-straightforward.

我需要能够以任何一种格式输入和输出数据。我们不需要担心合并的单元格、公式或任何非直接的东西。

1 个解决方案

#1


8  

If you have libreoffice installed, you can do a python execution wrapper around its headless mode:

如果你已经安装了libreoffice,你可以对它的无头模式做一个python执行包装:

$ /usr/bin/libreoffice --headless --invisible -convert-to ods /home/cwgem/Downloads/QTL_Sample_data.xls 
convert /home/cwgem/Downloads/QTL_Sample_data.xls -> /home/cwgem/QTL_Sample_data.ods using OpenDocument Spreadsheet Flat XML
$ /usr/bin/libreoffice --headless --invisible -convert-to xls /home/cwgem/QTL_Sample_data.ods 
convert /home/cwgem/QTL_Sample_data.ods -> /home/cwgem/QTL_Sample_data.xls using

Which would be a bit easier than trying to do it through the library route.

这要比尝试通过库路径来完成要容易一些。

#1


8  

If you have libreoffice installed, you can do a python execution wrapper around its headless mode:

如果你已经安装了libreoffice,你可以对它的无头模式做一个python执行包装:

$ /usr/bin/libreoffice --headless --invisible -convert-to ods /home/cwgem/Downloads/QTL_Sample_data.xls 
convert /home/cwgem/Downloads/QTL_Sample_data.xls -> /home/cwgem/QTL_Sample_data.ods using OpenDocument Spreadsheet Flat XML
$ /usr/bin/libreoffice --headless --invisible -convert-to xls /home/cwgem/QTL_Sample_data.ods 
convert /home/cwgem/QTL_Sample_data.ods -> /home/cwgem/QTL_Sample_data.xls using

Which would be a bit easier than trying to do it through the library route.

这要比尝试通过库路径来完成要容易一些。