pyExcelerator: writing multiple rows

P

patrick.waldo

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')
 
M

mensanator

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top