Vitalij Sawizki
Vitalij Sawizki

Reputation: 33

Python Tkinter output the importet data from a text widget

i try to write the entered data from a text entry into a excel file.

if i do:

address = invoice_address_entry.get("1.0",END)
for item in address:
    worksheet.write(row, col, item)
    row +=1

i get the data as a column

enter image description here

enter image description here

enter image description here

Upvotes: 0

Views: 50

Answers (1)

AKX
AKX

Reputation: 169388

Based on the symptoms,

address = invoice_address_entry.get("1.0",END)

returns a multi-line string. Iterating over a string yields the single characters in it.

If you want each line in it in a separate worksheet row, use .splitlines() first.

address = invoice_address_entry.get("1.0", END)
for item in address.splitlines():
    worksheet.write(row, col, item)
    row += 1

Upvotes: 1

Related Questions