wb = openpyxl.workbook.Workbook(encoding='utf-8') # replace utf-8 by the
encoding you're actually using in your database ;-)
By default, it's using utf-8, and make sure you've got the latest
version of openpyxl, as encoding was only added recently.
Cheers,
Eric
Le 7/11/11 14:08, pradnya a �crit :
I can give you a better answer later today once I have a chance to look at the code again.
Brent Hoover
Computer Scientist
323-687-3265
have a look there :
http://stackoverflow.com/questions/3224268/python-unicode-encode-error
When you're printing cell.value, actually you're trying to decode the
string contained inside value using your system default encoding. Try to
do "print cell.value.decode('utf-8')" if your workbook is in utf-8 for
example.
Cheers,
Eric
Le 11/11/11 07:08, pradnya a �crit :
> hi,
> Thanks for your reply.
> But Eric the version i am using is 1.5.6 and i m not creating object
> of workbook
> here is the code
>
> from openpyxl.reader.excel import load_workbook
> def main():
> wb = load_workbook(filename = u'test.xlsx')
> for sheet in wb.worksheets:
> for row in sheet.rows:
> for cell in row:
> print cell.value
>
> and the xlsx file contains two rows as
>
> 1 Subject Test 1
> 2 Question What is the banker�s algorithm ?
To get the apostrophe, I'd suggest to use a different encoding, that
contains the apostrophe. That's why it's important to know what is the
original encoding of your file, usually in europe, you can try 'latin1'
or 'utf-8' and get lucky.
Cheers,
Eric
Le 12/11/11 07:52, pradnya a �crit :
It's also possible that the spreadsheet is using 'latin-1' encoding rather than utf8. This is the default encoding for Windows and the right quotation mark would be an example of a character that would be not be the same between the two character sets.