Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个 Python 程序可以创建一个 Excel 工作表,但其中一位用户要求我对其进行修改,以便如果他点击打印,它将打印到横向模式,而无需他指定。有没有办法在 XLWT 或一些类似的 Python 库中将工作表设置为横向?
谢谢你。
使用 XLWT,我相信它很简单:
worksheetObject.portrait = False
我认为马克的回答对以前的版本有效,xlwt但从 0.7.5 版开始不起作用。以下工作代替:
xlwt
sheet.set_portrait(False)
请注意,它现在是工作表的属性,而不是整个工作簿的属性。