xlwt - 如何将分页符添加到Excel文件? [英] xlwt - How to add page breaks to an Excel File?
问题描述
如果列的值在Excel中使用Python更改,并尝试添加分页符,而 xlwt
I'm trying to add page breaks whenever a column's value changes in Excel using Python and xlwt.
有没有人知道如何做?
我发现一个例子,但他们并没有真正说出他们的代码是否有效,他们不会说什么数字意味着元组:
I found one example but they don't really say if their code works, and they don't say what the numbers mean in the tuple:
ws.horz_page_breaks = [(54, 0, 255), (108, 0, 255)]
推荐答案
做一些网络研究我发现此OpenOffice.org文档描述Excel的格式和BIFF记录。似乎是横向休息(第181页),每个元组表示:
Doing some web research I found this OpenOffice.org document describing Excel's format and BIFF records. It seems for horizontal breaks (pag. 181), each tuple represents:
- 第一行的索引以下分页符
- 分页首列的索引
- 分页上一列的索引
所以,对于你在问题中显示的例子,你有两个分页符,一个是行54,另一个是第108行,它们都是从第0列到第255列。
So, for the example you show in the question, you have two page breaks, one over row 54 and another one over row 108, both of them spanning from column 0 to column 255.
同样适用于垂直休息;只是在前面的描述中交换行和列。
Same applies for vertical breaks; just swap "row" and "column" in the previous description.
这篇关于xlwt - 如何将分页符添加到Excel文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!