This skill converts legacy Microsoft Office files to modern formats:
本技能用于将旧版 Microsoft Office 文件转换为现代格式:
Windows 系统 + Microsoft Word 已安装
使用 pywin32 通过 Word COM 接口进行转换,无需 LibreOffice。
Requires Windows OS and Microsoft Word installed. Uses pywin32 Word COM interface.
Python 包依赖 / Python Dependencies:
bash
pip install xlrd openpyxl
powershell
python <skill_dir>/scripts/doc_to_docx_com.py input.doc [output.docx]
powershell
python <skill_dir>/scripts/xls_to_xlsx.py input.xls [output.xlsx]
powershell
python <skill_dir>/scripts/doc_to_docx_com.py "C:\path\to\directory"
powershell
python <skill_dir>/scripts/xls_to_xlsx.py --batch "C:\path\to\directory"
Example 1: Batch convert all legacy files in current directory
powershell
# 转换所有 .doc 文件
python doc_to_docx_com.py "C:\Users\Documents"
# 转换所有 .xls 文件
python xls_to_xlsx.py --batch "C:\Users\Documents"
Example 2: Convert single file with output path
powershell
# .doc 转换
python doc_to_docx_com.py "input.doc" "output.docx"
# .xls 转换
python xls_to_xlsx.py "input.xls" "output.xlsx"
文件覆盖: 如果输出文件已存在,会被自动覆盖
临时文件: Word COM 转换会在同一目录生成临时文件,转换完成后自动清理
大文件: 超大 .xls 文件(>10MB)可能转换较慢
编码问题: 某些特殊字符可能出现编码问题,脚本已做处理
File Overwrite: Existing output files will be overwritten
Temp Files: Word COM creates temp files in same directory, auto-cleaned after conversion
Large Files: Very large .xls files (>10MB) may convert slowly
Encoding: Special characters are handled by the scripts
错误类型解决方法"pywin32 not found"运行: pip install pywin32"Word COM failed"确保 Word 已安装且可正常打开"xlrd import error"运行: pip install xlrd openpyxl"Permission denied"关闭正在使用的源文件ErrorSolution"pywin32 not found"Run: pip install pywin32"Word COM failed"Ensure Word is installed and can open files"xlrd import error"Run: pip install xlrd openpyxl"Permission denied"Close the source file if it's open