我正在尝试累积满足特定条件的 CellRanges,以便我可以一次性在整个范围内设置属性
rng=None
for c in Cell(1,1).vertical_range:
if c.value and c.value.endswith(' Total'):
rng=rng+c.horizontal_range if rng is not None else c.horizontal_range
rng.font.bold=True
对于累积更多 30 个区域左右的范围,我在下面遇到错误。导致错误的区域数量并不总是相同。所以我不能把手指放在一个特定的限制上。我确实使用了一种解决方法,即在累积了 20 个区域之后,我在范围上设置了所需的属性,然后重置了 CellRange,但是能够累积我需要的所有区域,这会受到区域数量的任何限制excel有
Traceback (most recent call last):
File "27/scriptStarter.py", line 128, in <module>
File "C:\Users\xxxx\rangebug.py", line 3, in <module>
rng=rng+c.horizontal_range if rng is not None else c.horizontal_range
File "27/basic_io.py", line 546, in __add__
File "27/basic_io.py", line 465, in __init__
File "27/basic_io.py", line 1022, in _cell_name_parser
File "27/basic_io.py", line 1136, in _named_range_parser
File "27/iron.py", line 139, in getNamedRange
File "27/dnparser.py", line 95, in checkForErrors
dntypes.NitroException: Exception from HRESULT: 0x800A03EC