Why the following code can't format 44000
to a date in excel? It shows up in xls file as the original number no matter what I try.
Things I have tried:
- Different format string, none works. I copy them from source file so no mistake here
- Check
style
object with breakpoint, it gets the correctnum_format_str
- quote or un-quote the number
I am using Mac Preview to open the xls file if that's relevant.
import xlwt
book = xlwt.Workbook(encoding='utf8')
sheet = book.add_sheet('sheet 1')
style = xlwt.easyxf(num_format_str="M/D/YY")
sheet.write(1, 1, 44000, style=style)
response = HttpResponse(mimetype='application/vnd.ms-excel')
response['Content-Disposition'] = 'attachment; filename=test.xls'
book.save(response)
return response