excel 转换成pdf

import os
from win32com.client import DispatchEx


def get_pdf(excel_path,pdf_path):
"""
excel 生成pdf
:param excel_path: excel 路径
:param pdf_path: pdf的保存路径 自动生成
:return:
"""
xlApp = DispatchEx("Excel.Application")
xlApp.Visible = False
xlApp.DisplayAlerts = 0
books = xlApp.Workbooks.Open(excel_path,False)
books.ExportAsFixedFormat(0, pdf_path)
books.Close(False)
xlApp.Quit()

posted @ 2023-10-07 09:53  郭峰g  阅读(31)  评论(0编辑  收藏  举报