我试图积累满足一定条件的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发布于 2014-05-22 18:40:30
这是我们软件中的一个bug --我们将对其进行调查并发布修复程序。
同时,你也可以这么做:
for c in Cell(1,1).vertical_range:
if c.value and c.value.endswith(' Total'):
c.horizontal_range.font.bold=Truehttps://stackoverflow.com/questions/23726087
复制相似问题