我正在尝试累积符合特定条件的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
答案 0 :(得分:1)
这是我们软件中的一个错误 - 我们会调查并发布修复程序。
与此同时,你可以这样做:
for c in Cell(1,1).vertical_range:
if c.value and c.value.endswith(' Total'):
c.horizontal_range.font.bold=True