5

I have a column heading Fee. Using xlwt in python, I successfully generated the required excel.This column is always blank at the creation of Excel file.

Is it possible to have the Fee column preformatted to 'Currency' and 'two decimal places', so that when I write manually in the Fee column of the Excel file after downloading, 23 should change into $23.00 ??

prasvin
  • 3,009
  • 23
  • 28
Abhaya
  • 2,086
  • 16
  • 21

1 Answers1

11

I got it working like this:

currency_style = xlwt.XFStyle()

currency_style.num_format_str = "[$$-409]#,##0.00;-[$$-409]#,##0.00"

sheet.write(row+2, col, val, style=currency_style)

Abhaya
  • 2,086
  • 16
  • 21
  • Can you please explain this, the values in `row`, `col` and `val`. The question was to auto-format values in the Fee column of the excel sheet when filling manually, so I was wondering if this code will be applied to the whole column of "Fee" without any looping. if there is a need for a for-loop how do I determine the number of rows that might be needed? – Pulath Yaseen Jun 17 '22 at 07:00