I need to write a data table in excel file. This data table has 7 rows and 1 column, and all the values are different. My problem is only last row is written in excel file.
What I need in excel:
FT 202003/69362
FT 202003/62581
FT 202003/41307
FT 202003/32316
FT 202003/4664
FT 201903/215090
FT 201903/197043
What is happening in excel:
FT 201903/197043
FT 201903/197043
FT 201903/197043
FT 201903/197043
FT 201903/197043
FT 201903/197043
FT 201903/197043
My code:
faturas = driver.find_elements_by_xpath("//p[@class='text-description-small']//b[contains(text(),'FT')]")
totalfaturas = len(faturas)
for i in range(totalfaturas):
fat = faturas[i].text
print(fat)
from openpyxl import *
nf = load_workbook("C:\WebDrivers\Fatturas.xlsx")
nf1 = nf.active
for n in range(1, totalfaturas+1):
nf1.cell(row=n,column=1).value=fat
nf.save("C:\WebDrivers\Fatturas.xlsx")
I can print the right data table in python, but I can't write this data table in excel. Can you please help me?
nf1.cell(row=n,column=1).value=fat=> this is wrong . why usingfathere ? just do same as you did in above loop , dynamically :)