在 CentOS 上如果没有 LibreOffice,可以根据你的使用场景用下面这些替代方案,从“最像 Office”到“命令行可用”都有:
如果只是“没装”,而不是“不能装”:
sudo yum install libreoffice
# 或最小化安装
sudo yum install libreoffice-writer libreoffice-calc
CentOS 7/8 默认仓库里一般都有。
# CentOS 官方源通常没有,需要手动下载
# https://openoffice.apache.org/
⚠️ 维护不如 LibreOffice 活跃,一般不建议新用。
.docx、.xlsx# 下载 rpm
sudo rpm -ivh wps-office-*.rpm
适合:需要兼容 Windows 文档格式
适合:
sudo yum install pandoc
pandoc a.docx -o a.md
✅ 不需要 GUI
❌ 不能“编辑”
Excel:
pip install openpyxl pandas
Word:
pip install python-docx
适合:
pandoc 转 PDF| 需求 | 推荐 |
|---|---|
| 看 docx | pandoc / catdoc |
| 转 PDF | libreoffice --headless |
| Excel 处理 | openpyxl |
| 服务器无界面 | LibreOffice headless |
libreoffice --headless --convert-to pdf file.docx
✅ 桌面用 → WPS / LibreOffice
✅ 服务器 → LibreOffice headless + Pandoc
✅ 自动化 → Python 库
如果你能说清楚:
我可以给你最合适的一条命令方案。