Получить данные из excel с помощью бота телеграммы python

Я пытаюсь получить данные из Excel с помощью python для отправки сообщения в боте телеграммы, например: пользователь вводит свой регион, он проверяет регион, после чего вводит номер и проверяет номер, и после того, как все пользователи получают данные. Спасибо.

Код:

        elif message.text.lower() == 'get data':
        path = "Test.xlsx"
        # To open the workbook
        # workbook object is created
        wb_obj = openpyxl.load_workbook(path)

        # Get workbook active sheet object
        # from the active attribute
        sheet_obj = wb_obj.active

        # Cell object is created by using
        # sheet object's cell() method.
        cell_obj = sheet_obj['A': 'B']
      
        # Print value of cell object
        # using the value attribute
        for cell1, cell2 in cell_obj:
            print('excel read')
        bot.send_message(message.chat.id, text='Enter region:', reply_markup=menu3)
        if message.text.lower() == cell1:
            bot.send_message(message.chat.id, text='Enter number:', reply_markup=menu3)
        if message.text.lower() == cell2:
            bot.send_message(message.chat.id, f'Your data:\n\n{cell2()}')

0 ответов

Другие вопросы по тегам