[wxPython-users] Save output to excel sheet
Jean Brouwers
mrjean1 at gmail.com
Tue Jun 12 08:24:16 PDT 2007
Maybe, the last for loop should be indented and inside the one above. Like
<pre>
...
for row_num,row_values in enumerate(values):
row_num+=3D1
print'row_num %d'% row_num
print'row_values %s' % values
for col,value in enumerate(row_values):
mysheet.write(row_num,col,value)
#print '%d %d %s' % (row_num,col,value)
...
</pre>
On 6/12/07, Thippana, Prasoonadevi <pthippan at mc.com> wrote:
>
> Hi,
>
> I have an output that is generated by a function. It is in a form of an
> array. The output looks like
>
> data [['NC7WZ16P6X', 'U115', 'I011308']]
> data [['NC7WZ16P6X', 'U116', 'I011308']]
> data [['NC7WZ16P6X', 'U117', 'I011308']]
> data [['NC7WZ16P6X', 'U118', 'I011308']]
> data [['NC7WZ16P6X', 'U122', 'I011308']]
> data [['ICL3224IA', 'U34', 'I011388']]
> data [['XC4VSX55-11FF1148', 'U90', 'I011405']]
> data [['LTC3729EUH', 'U56', 'I090381']]
> data [['LTC3729EUH', 'U59', 'I090381']]
> data [['LTC3729EUH', 'U60', 'I090381']]
> data [['LTC3729EUH', 'U62', 'I090381']]
> data [['SY89832UMI', 'U85', 'I090467']]
>
> I am trying to get this output into the excel sheet. The code for that
> function is
>
> def output(self,headers,values):
>
> mydoc=3Dxl.Workbook()
> mysheet=3Dmydoc.add_sheet("test")
> header_font=3Dxl.Font() #make a font object
> header_font.bold=3DTrue
> header_font.underline=3DTrue
> header_style =3D xl.XFStyle()
> header_style.font =3D header_font
>
> for col,value in enumerate(headers):
> mysheet.write(0,col,value,header_style)
> #print ' %d, %d, %s, %s ' % (0,col,value,header_style)
>
> for row_num,row_values in enumerate(values):
> row_num+=3D1
> print'row_num %d'% row_num
> print'row_values %s' % values
>
> for col,value in enumerate(row_values):
> mysheet.write(row_num,col,value)
> #print '%d %d %s' % (row_num,col,value)
>
> mydoc.save(r'C:testpyexel2.xlt')
>
> The don't have problem writing the headers. When I write the row values,
> its is overwriting all the values and I can get only the last row values.=
I
> don't understand where I am doing the mistake.
>
> Thanks
> Prasoona
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wxpython-users/attachments/200706=
12/0616115a/attachment.htm
More information about the wxpython-users
mailing list