Reputation: 559
from xlsxwriter import Workbook
from string import ascii_lowercase
letters=ascii_lowercase
workbook = Workbook('Expenses01.xlsx')
worksheet = workbook.add_worksheet('Results')
worksheet.set_column('K:K', None, None, {'hidden': True})
worksheet.set_column('O:O', None, None, {'hidden': True})
row=0
cell_format = workbook.add_format()
cell_format.set_bold()
cell_format.set_bg_color('brown')
cell_format.set_pattern(1)
cell_format.set_font_color('red')
worksheet.write(0, letters.index('j'),'PLEASE FILL PRICES IF FULL DATA PROVIDED',cell_format)
How can I change the cell size so entire text is shown, I don't want to change entire column size just this "header" cell. (i.e allow text to be written in two lines in one cell)
after adding cell_format.set_text_wrap()
Upvotes: 0
Views: 1025
Reputation: 2518
You have to use:
cell_format.set_text_wrap()
If you wish to adapter the height of the cell according to the text, you can use:
set_align('vjustify')
This information can be found at: https://xlsxwriter.readthedocs.io/format.html
Upvotes: 0
Reputation: 1213
(i.e allow text to be written in two lines in one cell)
This makes it seem like you want text wrapping within the cell. The Format
class has a set_text_wrap()
method that does this. Simply add the following line after your other format configuration.
cell_format.set_text_wrap()
Upvotes: 1