Получить значение строки из .xlsx с помощью Python и объединить результаты - PullRequest
0 голосов
/ 14 октября 2019

Я создаю простое приложение, которое может получить доступ к файлу .xlsx - прочитать значения (предоставленные пользователем) из диапазона строк и объединить эти значения, чтобы сформировать предложения. Это форма файла .xlsx, в которой принимаются начальные значения:

TranslationExcel

Файл, который необходимо вывести: OutPutFile

Количество строк из xlsx:

Form1

Каждое значение строки вводится в эти поля

Form2 Form3

import PySimpleGUI as sg

inputbox = 1 #Number of text boxes when App opens
layout = [[sg.Text('Rows Needed')], #Title Above TextBox
          *[[sg.InputText(),] for i in range(inputbox)], #Create text box (number of boxes defined by variable above)
          [sg.Button('Next'), sg.Exit()]] #Create Next+Exit Button

window = sg.Window('Translator', layout) #Creates window defined in 'Layout[]'

while True: #Infinite loop (always True)
    event, values = window.Read() #event=Button Click, #values=Values entered into field
    #print(event, values) #Prints button click+values in input
    if event in (None, 'Exit'): #If nothing happens break loop(or exit button clicked)
        break

    if event == 'Next': #Once the 'Next' is clicked
        sizeQtyNum = int(values[0]) #First inputed number is put into this variable
        layout = [[sg.Text('Input Text')], #Creates new layout with this text
                  *[[sg.InputText(),] for i in range(sizeQtyNum)], #Textboxes created (number defined by previously entered number)
                  [sg.Button('GetResults'), sg.Exit()]] #Create GetResults+Exit Button
        window1 = sg.Window('Translator', layout) #Creates new window defined in new layout (in this if statement)
        window.Close() #Closes old window
        window = window1 #Sets new window to equal the name of the first created
    if event == 'GetResults':
        wordList = values.copy() #Makes a new list and copies values from list inputed into sizes field previously
        sg.Popup('Title',
         'The results of the window.',
         'The button clicked was "{}"'.format(event),
         'The values are', values)

Теперь к вопросу:Я понятия не имею, как на самом деле получить всю строку из файла .xlsx, где первый столбец - это переменная, предоставленная пользователем, и затем объединить их в одну ячейку, разделенную по языкам. Любая помощь будет высоко ценится.

...