Python将Word转换成Excel
from pydocx import PyDocX
import pandas as pd
def word2excel(file):
#PyDocx转换
html_file=file.replace(".docx",".html")
excel_file=file.replace(".docx",".xlsx")
#先将doc转换成html
html = PyDocX.to_html(file)
f = open(html_file, "w", encoding='utf-8')
f.write(html)
f.close()
#将html转换成excel
table = pd.read_html(html_file)[0]
print(table)
table.to_excel(excel_file,index=False,header=False)
if __name__=="__main__":
word2excel("xxxxxx.docx")