pyExcelerator: writing multiple rows

mensanator at aol.com mensanator at aol.com
Sat Jan 19 12:37:26 EST 2008


On Jan 19, 7:46�am, patrick.wa... at gmail.com wrote:
> Hi all,
>
> I was just curious if there was a �built-in or a more efficient way to
> do take multiple rows of information and write them into excel using
> pyExcelerator. �This is how I resolved the problem:
>
> from pyExcelerator import *
>
> data = [[1,2,3],[4,5,'a'],['','s'],[6,7,'g']]
>
> wb=pyExcelerator.Workbook()
> test = wb.add_sheet("test")
>
> c=1
> r=0
> while r<len(data):
> � � for d in data[r]:
> � � � � test.write(r,c,d)
> � � � � c+=1
> � � r+=1
> � � c=1
> wb.save('c:\\1\\test.xls')

Try this:

for row,rowdata in enumerate(data):
  for col,cell in enumerate(rowdata):
    test.write(row,col,cell)


If you need row & col offsets, add them.

row_offset = 7
col_offset = 3
for row,rowdata in enumerate(data):
  for col,cell in enumerate(rowdata):
    test.write(row+row_offset,col+col_offset,cell)



More information about the Python-list mailing list