I'm using python with xlwt and have a problem
My code:
tickets = cursor.fetchall ()
largo = len(tickets)
cursor.close ()
conn.close ()
row = 4
for t in tickets:
hoja.write(row, 1, t[0])
hoja.write(row, 2, epoch2fecha(t[1]))
hoja.write(row, 3, epoch2fecha(t[12]))
hoja.write(row, 6, t[10])
hoja.write(row, 7, t[9])
hoja.write(row, 8, t[6])
hoja.write(row, 9, t[3])
row += 1
if(row == largo+1):
break
libro.save('Informe.xls')
Error:
libro.save('informe.xlsx')
File "build/bdist.linux-x86_64/egg/xlwt/Workbook.py", line 662, in save
File "build/bdist.linux-x86_64/egg/xlwt/Workbook.py", line 637, in get_biff_data
File "build/bdist.linux-x86_64/egg/xlwt/Workbook.py", line 599, in __sst_rec
File "build/bdist.linux-x86_64/egg/xlwt/BIFFRecords.py", line 76, in get_biff_record
File "build/bdist.linux-x86_64/egg/xlwt/BIFFRecords.py", line 91, in _add_to_sst
File "build/bdist.linux-x86_64/egg/xlwt/UnicodeUtils.py", line 50, in upack2
UnicodeDecodeError: 'ascii' codec can't decode byte 0xf3 in position 6: ordinal not in range(128)
Have you tried encoding latin-1 for workbook??
from xlwt import Workbook
hoja = Workbook(encoding='latin-1')
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