Hi there, I am trying to put data including Chinese Characters into Excel through python. But I got some problems. Here is my sample code:
################################################## # import win32com.client xlapp = win32com.client.DispatchEx("Excel.Application") xlbook = xlapp.Workbooks.Open("test.xls") sht = xlbook.Worksheets("Sheet1") # data is provided in case 1 and case 2 below ... sht.Range(sht.Cells(1, 1), sht.Cells(2,4)).Value = data # ################################################## Using the above code, I tested two cases for "data". The "data" from both two cases are same: tuple basically. But in case 1, only 2222 and 3333 are inserted into Excel. All other cells are blank. in case2, all data including Chinese Characters are inserted into Excel and everything is fine. My real data is like case 1. #case 1 ------------------------------------------ rp = {'r1':['\xd6\xd7\xc1\xf6','\xd6\xd7\xc1\xf6'], 'r2':['\xd6\xd7\xc1\xf6','\xd6\xd7\xc1\xf6'], 'r3':[2222,3333], 'r4':['\xd6\xd7\xc1\xf6','\xd6\xd7\xc1\xf6'] } b = () for k in range(len(rp['r1'])): a = rp['r1'][k],rp['r2'][k],rp['r3'][k],rp['r4'][k] if len(b) == 0: b = a else: b = b,a data = b #case 2 ------------------------------------------ data =(('\xd6\xd7\xc1\xf6', '\xd6\xd7\xc1\xf6', 2222, '\xd6\xd7\xc1\xf6'), ('\xd6\xd7\xc1\xf6", '\xd6\xd7\xc1\xf6", 3333, '\xd6\xd7\xc1\xf6')) Anybody knows what is going on with it? Thanks for your help. Ouyang -- http://mail.python.org/mailman/listinfo/python-list