美文网首页
2022-06-21EXCEL批量转pdf

2022-06-21EXCEL批量转pdf

作者: candel | 来源:发表于2022-06-21 14:22 被阅读0次

import os
import xlwings as xw

def excel2pdf(file):
app = xw.App(visible=True,add_book=False)
wb = app.books.open(file)
sht = wb.sheets[0]
current_work_dir = os.getcwd()
pdffile= file.strip('xls')+'pdf'
pdf_path = os.path.join(current_work_dir, pdffile)
sht.api.ExportAsFixedFormat(0, pdf_path)

filelist = os.listdir('./')
for file in filelist:
excel2pdf(file)

相关文章

网友评论

      本文标题:2022-06-21EXCEL批量转pdf

      本文链接:https://www.haomeiwen.com/subject/nucevrtx.html