将文档ODF转换为DOC

$ unoconv -d document --format=doc document.odt 
$ file document.doc
document.doc: Composite Document File V2 Document, Little Endian, Os: Windows

将文档ODF转换为DOCX

$ unoconv -d document --format=docx document.odt 
$ file document.docx 
document.docx: Microsoft Word 2007+

将电子表格XLS转换为ODS

$ unoconv -d spreadsheet --format=ods spreadsheet.xls 
$ file spreadsheet.ods 
spreadsheet.ods: OpenDocument Spreadsheet
Linux上如何在LibreOffice和Microsoft Office之间进行格式转换

我们将学习如何在Linux上在LibreOffice和Microsoft Office文件格式之间转换文档格式。

在LibreOffice和Microsoft Office之间进行文件格式转换时,首选的工具是“unoconv”。让我们从安装“unoconv”包开始:

FEDORA/REDHAT/CENTOS
# yum install unoconv
DEBIAN/UBUNTU
# apt-get install unoconv

创建一些LibreOffice文档document.odt和电子表格spreadsheet.ods以便测试:

$ file document.odt 
document.odt: OpenDocument Text
$ file spreadsheet.ods 
spreadsheet.ods: OpenDocument Spreadsheet

“unoconv”命令能够在各种文件格式之间进行转换。要查看“unoconv”支持的所有文件格式的列表,请运行:

$ unoconv --show
The following list of document formats are currently available:
  bib      - BibTeX [.bib]
  doc      - Microsoft Word 97/2000/XP [.doc]
  doc6     - Microsoft Word 6.0 [.doc]
  doc95    - Microsoft Word 95 [.doc]
  docbook  - DocBook [.xml]
  docx     - Microsoft Office Open XML [.docx]
  docx7    - Microsoft Office Open XML [.docx]
  fodt     - OpenDocument Text (Flat XML) [.fodt]
  html     - HTML Document (OpenOffice.org Writer) [.html]
  latex    - LaTeX 2e [.ltx]
  mediawiki - MediaWiki [.txt]
  odt      - ODF Text Document [.odt]
  ooxml    - Microsoft Office Open XML [.xml]
  ott      - Open Document Text [.ott]
  pdf      - Portable Document Format [.pdf]
  rtf      - Rich Text Format [.rtf]
  stw      - Open Office.org 1.0 Text Document Template [.stw]
  sxw      - Open Office.org 1.0 Text Document [.sxw]
  text     - Text Encoded [.txt]
  txt      - Text [.txt]
  uot      - Unified Office Format text [.uot]
  xhtml    - XHTML Document [.html]
The following list of graphics formats are currently available:
  bmp      - Windows Bitmap [.bmp]
  emf      - Enhanced Metafile [.emf]
  eps      - Encapsulated PostScript [.eps]
  fodg     - OpenDocument Drawing (Flat XML) [.fodg]
  gif      - Graphics Interchange Format [.gif]
  html     - HTML Document (OpenOffice.org Draw) [.html]
  jpg      - Joint Photographic Experts Group [.jpg]
  met      - OS/2 Metafile [.met]
  odd      - OpenDocument Drawing [.odd]
  otg      - OpenDocument Drawing Template [.otg]
  pbm      - Portable Bitmap [.pbm]
  pct      - Mac Pict [.pct]
  pdf      - Portable Document Format [.pdf]
  pgm      - Portable Graymap [.pgm]
  png      - Portable Network Graphic [.png]
  ppm      - Portable Pixelmap [.ppm]
  ras      - Sun Raster Image [.ras]
  std      - OpenOffice.org 1.0 Drawing Template [.std]
  svg      - Scalable Vector Graphics [.svg]
  svm      - StarView Metafile [.svm]
  swf      - Macromedia Flash (SWF) [.swf]
  sxd      - OpenOffice.org 1.0 Drawing [.sxd]
  tiff     - Tagged Image File Format [.tiff]
  wmf      - Windows Metafile [.wmf]
  xhtml    - XHTML [.xhtml]
  xpm      - X PixMap [.xpm]
The following list of presentation formats are currently available:
  bmp      - Windows Bitmap [.bmp]
  emf      - Enhanced Metafile [.emf]
  eps      - Encapsulated PostScript [.eps]
  fodp     - OpenDocument Presentation (Flat XML) [.fodp]
  gif      - Graphics Interchange Format [.gif]
  html     - HTML Document (OpenOffice.org Impress) [.html]
  jpg      - Joint Photographic Experts Group [.jpg]
  met      - OS/2 Metafile [.met]
  odg      - ODF Drawing (Impress) [.odg]
  odp      - ODF Presentation [.odp]
  otp      - ODF Presentation Template [.otp]
  pbm      - Portable Bitmap [.pbm]
  pct      - Mac Pict [.pct]
  pdf      - Portable Document Format [.pdf]
  pgm      - Portable Graymap [.pgm]
  png      - Portable Network Graphic [.png]
  potm     - Microsoft PowerPoint 2007/2010 XML Template [.potm]
  pot      - Microsoft PowerPoint 97/2000/XP Template [.pot]
  ppm      - Portable Pixelmap [.ppm]
  pptx     - Microsoft PowerPoint 2007/2010 XML [.pptx]
  pps      - Microsoft PowerPoint 97/2000/XP (Autoplay) [.pps]
  ppt      - Microsoft PowerPoint 97/2000/XP [.ppt]
  pwp      - PlaceWare [.pwp]
  ras      - Sun Raster Image [.ras]
  sda      - StarDraw 5.0 (OpenOffice.org Impress) [.sda]
  sxd      - OpenOffice.org 1.0 Drawing (OpenOffice.org Impress) [.sxd]
  sti      - OpenOffice.org 1.0 Presentation Template [.sti]
  svg      - Scalable Vector Graphics [.svg]
  svm      - StarView Metafile [.svm]
  swf      - Macromedia Flash (SWF) [.swf]
  sxi      - OpenOffice.org 1.0 Presentation [.sxi]
  tiff     - Tagged Image File Format [.tiff]
  uop      - Unified Office Format presentation [.uop]
  wmf      - Windows Metafile [.wmf]
  xhtml    - XHTML [.xml]
  xpm      - X PixMap [.xpm]
The following list of spreadsheet formats are currently available:
  csv      - Text CSV [.csv]
  dbf      - dBASE [.dbf]
  dif      - Data Interchange Format [.dif]
  fods     - OpenDocument Spreadsheet (Flat XML) [.fods]
  html     - HTML Document (OpenOffice.org Calc) [.html]
  ods      - ODF Spreadsheet [.ods]
  ooxml    - Microsoft Excel 2003 XML [.xml]
  ots      - ODF Spreadsheet Template [.ots]
  pdf      - Portable Document Format [.pdf]
  slk      - SYLK [.slk]
  stc      - OpenOffice.org 1.0 Spreadsheet Template [.stc]
  sxc      - OpenOffice.org 1.0 Spreadsheet [.sxc]
  uos      - Unified Office Format spreadsheet [.uos]
  xhtml    - XHTML [.xhtml]
  xls      - Microsoft Excel 97/2000/XP [.xls]
  xls5     - Microsoft Excel 5.0 [.xls]
  xls95    - Microsoft Excel 95 [.xls]
  xlt      - Microsoft Excel 97/2000/XP Template [.xlt]
  xlt5     - Microsoft Excel 5.0 Template [.xlt]
  xlt95    - Microsoft Excel 95 Template [.xlt]

默认情况下,所有文档都转换为PDF。使用“---format”选项将输出文件格式更改为上述任何格式。Unoconv的“-d”用于明确指定文档类型,例如文档、图形、演示文稿和电子表格。下面是几个如何在LibreOffice和Microsoft Office文档及电子表格文件格式之间转换的示例。

将电子表格ODS转换为XLS

$ unoconv -d spreadsheet --format=xls spreadsheet.ods 
$ file spreadsheet.xls 
spreadsheet.xls: Composite Document File V2 Document, Little Endian, Os: Windows

将文档DOCX转换为ODF

$ unoconv -d document --format=odt document.docx
$ file document.odt 
document.odt: OpenDocument Text
日期:2020-07-07 20:54:57 来源:oir作者:oir