开发者

Setting an excel sheet in landscape mode from XLWT

开发者 https://www.devze.com 2023-01-07 08:49 出处:网络
I have a Python program that creates an excel sheet, but I ha开发者_如何学Cve been asked by one of the users to modify it so that if he hits print it will print out to landscape mode, without him havi

I have a Python program that creates an excel sheet, but I ha开发者_如何学Cve been asked by one of the users to modify it so that if he hits print it will print out to landscape mode, without him having to specify this. Is there some way to set the sheet to landscape in XLWT or some similar Python library for excel?

Thank you.


With XLWT, I believe it's as easy as:

worksheetObject.portrait = False


I think Mark's answer was valid with previous versions of xlwt, it does not work as of version 0.7.5. The following works instead:

sheet.set_portrait(False)

Notice it is now a property of the sheet, not of the whole workbook.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号