# Function to take data from GUI
# window and write to an excel file
def insert():
# if user not fill any entry
# then print "empty input"
if (name_field.get() == "" and
course_field.get() == "" and
sem_field.get() == "" and
form_no_field.get() == "" and
contact_no_field.get() == "" and
email_id_field.get() == "" and
address_field.get() == ""):
print("empty input")
else:
# assigning the max row and max column
# value upto which data is written
# in an excel sheet to the variable
current_row = sheet.max_row
current_column = sheet.max_column
# get method returns current text
# as string which we write into
# excel spreadsheet at particular location
sheet.cell(row=current_row + 1, column=1).value = name_field.get()
sheet.cell(row=current_row + 1, column=2).value = course_field.get()
sheet.cell(row=current_row + 1, column=3).value = sem_field.get()
sheet.cell(row=current_row + 1, column=4).value = form_no_field.get()
sheet.cell(row=current_row + 1, column=5).value = contact_no_field.get()
sheet.cell(row=current_row + 1, column=6).value = email_id_field.get()
sheet.cell(row=current_row + 1, column=7).value = address_field.get()
# save the file
wb.save('C:\\Users\\Admin\\Desktop\\excel.xlsx')
# set focus on the name_field box
name_field.focus_set()
# call the clear() function
clear()
0.0000
0
4
关注作者
收藏
发表评论
暂无数据

