String variable in Xlsxwriter Python

I'm kind of new to python, and I was making a program with Tkinter that allowed me to write things in another excel file without actually opening the Excel file.

From tkinter, I added an input field that I would have to write, and a button that xlsxwriter will use to write the value in excel format.

I tried

    name_entry = StringVar()
    name_get = name_entry.get()
    e1 = Entry(root, textvariable = name_entry)
    b1 = Button(root, text = "Create")
    e1.pack()
    b1.bind("<Button-1>", create)
    b1.pack()

function "create" -

    def create(event):
        workbook = xlsxwriter.Workbook(0, "2016" + str(name_get))
        worksheet = workbook.add_worksheet()
        worksheet.write(0, 0, 'name')
        worksheet.write(1, 0, str(name_get))
        workbook.close

When I run the program and write something in the entries, and (b1), the excel file that it creates has only a name written in row = 0 and column = 0, but I do not have the name that I wrote in the input field in row = 1 and in column = 0. In addition, the name of the created file will be saved only as "2016", 2016 "+ str (name_get), the value I wrote in the input field.

In addition, the program has no errors

, excel?

, excel (, CSV , ) xlsxwriter?

, , - !

+4
2

, :

   workbook = xlsxwriter.Workbook(0, "2016" + str(name_get))

: Workbook(filename[, options])

, :

   workbook = xlsxwriter.Workbook("2016" + str(name_get))

, excel (, CSV , ) xlsxwriter?

.

XlsxWriter xlsx, .xlsx, Excel , .

0

, workheet.write.

worksheet.write_string().

http://xlsxwriter.readthedocs.io/worksheet.html?highlight=write_string#write_string

. -

name_entry = ''
worksheet.write_string(1,0, name_entry)
0

Source: https://habr.com/ru/post/1628406/


All Articles