python - xlwings将xlsx打印为pdf
import os, xlwings as xw
app = xw.App(visible=False, add_book=False) # visible操作是否可视化, add_book打开excel是否新建excel表
book = app.books.open(os.path.join(os.getcwd(), 'test.xlsx'))
sheet = book.sheets['sheet1']
sheet.api.ExportAsFixedFormat(0, os.path.join(os.getcwd(), 'test1.pdf')) # 打印工作表操作
book.api.ExportAsFixedFormat(0, os.path.join(os.getcwd(), 'test2.pdf')) # 打印整个工作簿操作
book.close()
app.quit()