Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- out_xlsx=r'C:\tmp\output.xlsx'
- out_xls=r'C:\tmp\output.xls'
- df.to_excel(out_xlsx, index=False, engine='xlsxwriter')
- ps = 'script.ps1'
- with open(ps, 'w') as f:
- f.write(textwrap.dedent('''\
- param ($inputFile, $outputFile)
- $myDir = split-path -parent $MyInvocation.MyCommand.Path
- $Excel = New-Object -ComObject Excel.Application
- $wb = $Excel.Workbooks.Open($inputFile)
- $wb.SaveAs($outputFile, 56)
- $Excel.Quit()
- '''))
- p = subprocess.Popen(['powershell.exe',
- '-ExecutionPolicy', 'Bypass',
- '.\\' + ps,
- '"' + out_xlsx + '"',
- out_xls])
- p.communicate()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement