使用 openpyxl 折叠多行 [英] Folding multiple rows with openpyxl

查看:79
本文介绍了使用 openpyxl 折叠多行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法使用 openpyxl 折叠多行?似乎没有与 openpyxl 简单用法页面上的示例等效的行.

Is there a way to fold multiple rows using openpyxl? There doesn't appear to be a row equivalent to the example found on the openpyxl simple usage page.

import openpyxl
wb = openpyxl.Workbook(True)
ws = wb.create_sheet()
ws.column_dimensions.group('A','D', hidden=True)
wb.save('group.xlsx')

推荐答案

不,没有等价物,但行更容易处理,因为它们总是在那里,ColumnDimensions 创建于要求.只需设置要隐藏的行.

No, there isn't an equivalent but rows are slightly easier to deal with because they are always there, ColumnDimensions are created on demand. Simply set the rows you want to hidden.

例如.隐藏第 5 到 9 行:

Eg. to hide rows 5 to 9:

for idx in range(5, 10):
    ws.row_dimensions[idx].hidden = True

这篇关于使用 openpyxl 折叠多行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆