Nov-15-2018, 08:06 PM
I have got a problem with Polish characters in xlsx file(words do not have Polish letters that have disappeared in an unknown way), which I take from table. What am I doing wrong?
import os import cx_Oracle import xlsxwriter con = cx_Oracle.connect('user/password@SID') cur = con.cursor() custdata =[] def main(): L_sFilename ="List_PNA.xlsx" workbook = xlsxwriter.Workbook(L_sFilename) worksheet = workbook.add_worksheet() format = workbook.add_format({'bold': True, 'font_color': 'red'}) format.set_font_name('Times New Roman') format.set_align('center') worksheet.write('A1','PNA',format) worksheet.set_column('A:A', 60) worksheet.write('B1','BOX',format) worksheet.set_column('B:B', 60) worksheet.write('C1','NAME',format) worksheet.set_column('C:C', 60) worksheet.write('D1','PO',format) worksheet.set_column('D:D', 60) worksheet.write('E1','STREET',format) worksheet.set_column('E:E', 60) worksheet.write('F1','NUMBERS',format) worksheet.set_column('F:F', 60) worksheet.write('G1','CITY',format) worksheet.set_column('G:G', 60) worksheet.write('H1','PROVINCE',format) worksheet.set_column('H:H', 60) worksheet.write('I1','DISTRICT',format) worksheet.set_column('I:I', 60) worksheet.write('J1','COMMUNE',format) worksheet.set_column('J:J', 60) format2 = workbook.add_format() format2.set_align('center') format2.set_font_color('black') format2.set_font_name('Times New Roman') L_sSelect ="""select * from my_xml_schema.LIST_PNA_TAB""" cur.arraysize = 100 cur.execute(L_sSelect) for result in cur: custdata.append((result)) cur.close() con.close() for r, row in enumerate(custdata,1): for c, col in enumerate(row): a=str(col) cell = unicode(a, errors='ignore') worksheet.write(r, c, cell,format2) #print " r= "+str(r) + " c= "+str(c) + " val= "+cell workbook.close() os.startfile(os.getcwd()+"\\"+L_sFilename) if __name__ == "__main__": main()