Mensanator
1/19/2008 5:37:00 PM
On Jan 19, 7:46?am, patrick.wa...@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)