Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

put style and background color python excel

Tags:

python

excel

i want to make excel value to center align and have a yellow background color. But i can't input too many arguments. So i try this one but it's nothing happen. Is there any other way to do it?

colorCenter = xlwt.XFStyle()

xlwt.add_palette_colour("custom_colour", 0x21)
wb.set_colour_RGB(0x21, 255, 255, 0)
color = xlwt.easyxf('pattern: pattern solid, fore_colour custom_colour')

colorCenter.color = color

alignment = xlwt.Alignment()
alignment.horz = xlwt.Alignment.HORZ_CENTER
center = xlwt.XFStyle()

colorCenter.center = center

sheet.write(11, 3, 'value', colorCenter)
like image 391
lalalala Avatar asked Sep 15 '26 07:09

lalalala


1 Answers

use easyxf is the best. you can put align, font, and pattern

colorCenter = easyxf('pattern: pattern solid, fore_colour yellow;'
                      'align: horiz center;')
like image 110
lalalala Avatar answered Sep 17 '26 20:09

lalalala



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!