Feature request: Conditional Formatting Data Bar Formatting
See original GitHub issueHello,
My company is currently using XlsxWriter to write complex excel spreadsheets programmatically. Almost every feature we have wanted has been included already which has been really useful. The only thing missing for our use case is formatting Conditional Formatting when they are Data Bars.
The specific formatting options of interest can be seen in this image (note: Mac 2011 version of UI): What we are interested in:
- Have a choice for setting the fill to either solid or gradient which currently defaults to gradient in your current implementation
- Have the ability to choose positive and negative color values for the bar which is currently just one color by default
- Have the ability to set Borders with positive and negative color values which is currently set to None by default
- Be able to set Axis Position to Automatic, Midpoint, None which is currently set to None by default
We would not mind helping implement these features on a fork as described in CONTRIBUTING.md and submit a pull request. I just wanted to discuss this with you before we started this so we can discuss:
- Do you want to include this feature into XlsxWriter
- How best would it be to add this to the conditional formatting api without breaking current implementation
- Is there anything else we need to consider before we attempt this
Proposal for how this would work:
worksheet.conditional_format(
'A1:A12',
{'type': 'data_bar',
'bar_color': 'pink' # also represents positive bar color,
'bar_fill': 'solid', # 'gradient' if not specified, options are 'gradient' and 'solid'
'negative_bar_color': 'blue', # set to bar_color by default
'border': 'solid', # None by default but can be set to 'solid'
'border_color': 'red', # Positive color value, also negative if negative is not set
'border_negative_color': 'black', # border_color by default
'axis_position': 'midpoint', # Can be 'midpoint', 'automatic' or None with None by default
'axis_color': 'orange' #color of axis if automatic or midpoint})
I haven’t looked through all the other conditional formatting code but if any of those names would cause conflict then add data_bar to the name when appropriate.
Please let me know what you think. Also if any of these features are already implemented but I missed them in documentation and source code then please let me know.
Issue Analytics
- State:
- Created 9 years ago
- Comments:12 (6 by maintainers)
Top GitHub Comments
Hi John,
I finished up my initial implementation yesterday(without required documents/test cases so not ready for pull request by any means). I based it off a file generated by Excel 2013, but will finalize my implementation when I get a 2010 version of Excel. I extended the use of ExtList at the end of worksheet xml creation and actually hid the feature under the workbook.excel_version = ‘2010’ so that when it is set to ‘2007’ the extra xml is not generated otherwise. I will be touching up my code next week and hopefully I can get it tested and ready for pull request and then we can discuss my implementation. I have a windows computer so I will get Excel 2010 on it to do this testing.
Alex
Alex
Full support for Excel 2010 style data bars has been added in XlsxWriter version 1.0.3.