I need help with openpyxl in PYTHON. I have successfully used xlwt, but now I have several files (in MySQL Workbench) that contain more than 65,000 lines. I know that I can create a CSV file, but XLSX is the preferred output. I can create a book using openpyxl, but I was unable to place MySQL data in a table. The bulk of the program using xlwt is fairly simple (see below). I just can't figure out how to do the same using openpyxl. I have tried several different combinations and solutions. I just got stuck after "for x as a result:".
file_dest = "c:\home\test.xls"
result = dest.execute("select a, b, c, d from filea)
for x in result:
rw = rw + 1
sheet1 = book.add.sheet('Sheet 1')
row1 = sheet1.row(rw)
row1.write(1,x[0])
row1.write(1,x[1])
row1.write(1,x[2])
row1.write(1,x[3])
book.save(file_dest)
source
share