XlsxWriter: Create a solid filled data bar

I have successfully generated a data plot using the python xlsxwriter module by its conditional_format method. However, is it possible to specify a condition format fill pattern in xlswriter or python in general? I tried the following code which didn't work:

myformat = workbook.add_format()
myformat .set_pattern(1)
worksheet.conditional_format(0, 4, 0, 4, {'type': 'data_bar',
                                                  'min_value': 0,
                                                  'min_type': 'num',
                                                  'max_value': 110,
                                                  'max_type': 'num',
                                                  'bar_color': '#C00000',
                                                  'format': myformat})

      

+3


source to share


1 answer


You can set a format template for some conditional formats using the XlsxWriter.

However, as far as I know, it is not possible in Excel to set the patten type for conditional formats data_bar

.

You can do it with the cell format:



import xlsxwriter

workbook = xlsxwriter.Workbook('hello_world3.xlsx')
worksheet = workbook.add_worksheet()

myformat = workbook.add_format()
myformat.set_pattern(1)
myformat.set_bg_color('#C00000')


worksheet.conditional_format(0, 4, 0, 4, {'type': 'cell',
                                          'criteria': 'between',
                                          'minimum':  0,
                                          'maximum':  110,
                                          'format':   myformat})

worksheet.write(0, 4, 50)


workbook.close()

      

If, on the other hand, you are looking for a non-gradient fill data_bar

which is currently not supported.

+3


source







All Articles