将openpyxl Excel工作表更改为横向方向

时间:2018-05-07 01:11:12

标签: python openpyxl

我已经尝试过失败的时间超过了我承认的时间。我已阅读文档。难住了。任何指导非常感谢!!!谢谢... Ellie The Good Dog

这个块没关系:

import openpyxl
myexcel = openpyxl.Workbook()
mysheet = myexcel.active
mysheet['A1'] = 'Test'
mysheet.print_area = 'A1:Z1'
myexcel.save(r'C:\Temp\Testing.xlsx')

此块失败:

from openpyxl.worksheet import page
mysheet.page.orientation = 'landscape'
mysheet.orientation = 'landscape'
mysheet.worksheet.ORIENTATION_LANDSCAPE = 'landscape'
mysheet.worksheet.page.ORIENTATION_LANDSCAPE = 'landscape'
mysheet.worksheet.ORIENTATION = 'landscape'
mysheet.worksheet.page.ORIENTATION = 'landscape'

1 个答案:

答案 0 :(得分:1)

尝试更改打印机设置:

openpyxl.worksheet.worksheet.Worksheet.set_printer_settings(worksheetObject, paper_size = <someInt>, orientation='landscape')