首页 > 解决方案 > xlsxwriter 条件格式数据栏选项不起作用

问题描述

我正在尝试使用xlsxwriter扩展具有条件格式数据条的表格。出于某种原因,这似乎只在我指定没有可选参数的代码或仅使用颜色更改参数时才有效。其他参数都不起作用('data_bars_2010', 'bar_direction', 'bar_negative_color_same')

使用条件格式的文档说您需要 excel 2010 或更高版本,我目前使用的是 2013 版本。也许这与我的版本xlsxwriter不是最新的有关。

就代码而言:这个基本示例有效:

worksheet8.conditional_format('B3:B14', {'type': 'data_bar'})

worksheet8.conditional_format('F3:F14', {'type': 'data_bar',
                                         'bar_color': '#63C384'})

但是这些更程式化的选项不起作用,并且根本不会显示任何条形。

worksheet8.conditional_format('J3:J14', {'type': 'data_bar',
                                         'bar_direction': 'right'})

worksheet8.conditional_format('L3:L14', {'type': 'data_bar',
                                         'data_bar_2010': True})

worksheet8.conditional_format('M3:N14', {'type': 'data_bar',
                                         'bar_negative_color_same': True,
                                         'bar_negative_border_color_same': True})

标签: pythonexcelconditional-formattingxlsxwriter

解决方案


你完全正确。一旦我更新到 xlsxwriter 1.3.3,数据栏就可以工作了!


推荐阅读