HyperLink Style is not working using set_column in xlsxwriter python

Viewed 129

I am using python xlsxwriter library to create excel. I need to apply background color to the cell for that I am using set_column method. All columns getting backgroundcolor except the column containing hyperlink. I tried various ways i can try with but not able to found anything. Cell format is working with write_rows but not with set_column containing hyperlink. Can anybody please help.

Sample Code:


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

cell_format = workbook.add_format()

cell_format.set_bg_color('green')

worksheet.write('A1', 'https://google.com')
worksheet.set_column(0, 0, None, cell_format)

workbook.close()

Output:

enter image description here

All columns have green color except having url.

1 Answers

Got the solution for this. There is parameter strings_to_urls which will consider url as string and then bgcolor will get applied.

workbook = Workbook(filename, {'strings_to_urls': False})

We can use this and then we will get bgcolor applied to url as well but it will no more be hyperlink.

Related