简体   繁体   English

范围联合上的 xlsxwriter 条件格式

[英]xlsxwriter conditional formatting on a union of ranges

I am trying to apply conditional formatting to a union of ranges in excel, however, it does not seem to be working.我正在尝试将条件格式应用于 excel 中的范围联合,但是,它似乎不起作用。 This is the code I am trying to execute ( ws is the excel writer's worksheet):这是我要执行的代码( ws是 excel 编写者的工作表):

ws.conditional_format('K13:O27, K35:037', {'type': '3_color_scale',
                                       'min_color': '#F8696B',
                                       'mid_color': 'white',
                                       'max_color': '#63BE7B',
                                       'mid_value': '0',
                                       'mid_type': 'num'})

but I am getting the following error message:但我收到以下错误消息:

cell_1, cell_2 = args[0].split(':')
ValueError: too many values to unpack (expected 2)

Does anyone know if this is doable, and if yes - what is the format of the union operator I should use on my cell_range input variable?有谁知道这是否可行,如果可行 - 我应该在 cell_range 输入变量上使用联合运算符的格式是什么?

Yes.是的。 That is possible using the conditional_format() multi_range parameter:这可以使用conditional_format() multi_range参数:

ws.conditional_format('K13:O27', {'type': '3_color_scale',
                                  'min_color': '#F8696B',
                                  'mid_color': 'white',
                                  'max_color': '#63BE7B',
                                  'mid_value': '0',
                                  'mid_type': 'num',
                                  'multi_range': 'K13:O27 K35:037'})

See the multi_range section of the XlsxWriter docs on Working with Conditional Formatting .请参阅有关使用条件格式的 XlsxWriter 文档的multi_range部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM