I am using xlwt, excel sheet generation module for python. Basically I am trying to use some styles for the text. The coloring part works fine .i.e.
import xlwt
workbook = xlwt.Workbook(encoding='ascii')
worksheet = workbook.add_sheet('Test sheet')
worksheet.write(0, 0, "Hello World", xlwt.easyxf("pattern: pattern solid, fore_color yellow; font: color white;"))
There was a need to add alignment as well. I found this working
alignment = xlwt.Alignment()
alignment.horz = xlwt.Alignment.HORZ_RIGHT
horz_style = xlwt.XFStyle()
horz_style.alignment = alignment
worksheet.write(0, 0, "Hello World", horz_style)
But now whole thing is messed up since I can use only either the coloring or alignment.What I am trying is to integrate the alignment feature with xlwt.easyxf as well
It was as simple as adding align: horiz right
import xlwt
workbook = xlwt.Workbook(encoding='ascii')
worksheet = workbook.add_sheet('Test sheet')
worksheet.write(0, 0, "Hello World", xlwt.easyxf("pattern: pattern solid, fore_color yellow; font: color white; align: horiz right"))
worksheet.save()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With