Skip to content

Instantly share code, notes, and snippets.

@victory-sokolov
Created December 31, 2019 09:26
Show Gist options
  • Save victory-sokolov/97968c9962bd555e4c2a33e1b363fd33 to your computer and use it in GitHub Desktop.
Save victory-sokolov/97968c9962bd555e4c2a33e1b363fd33 to your computer and use it in GitHub Desktop.
Converts xlsx,csv to PDF file
# Note Microsoft Excel must be installed
from openpyxl import Workbook, load_workbook
from win32com.client import Dispatch
path = os.path.dirname(os.path.abspath(__file__))
o = Dispatch("Excel.Application")
o.Visible = False
o.DisplayAlerts = False
wb = o.Workbooks.Open(path+"\\file.xlsx")
wb.WorkSheets("uzskaites lapa").Select()
wb.ActiveSheet.ExportAsFixedFormat(0, path+"\\test.pdf")
o.Quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment