Complete the code to import the library needed to read Excel files.
import [1]
The openpyxl library is used to read Excel files in Python.
Complete the code to load the Excel workbook named 'data.xlsx'.
workbook = openpyxl.[1]('data.xlsx')
Workbook which creates a new fileread_excel which is not in openpyxlThe load_workbook function from openpyxl loads an existing Excel file.
Fix the error in accessing the active sheet from the workbook.
sheet = workbook.[1]get_active_sheet()active_sheetThe correct property to get the active sheet is active.
Fill both blanks to read the value from cell A1 in the active sheet.
value = sheet.[1]('[2]').value
cells instead of cellUse sheet.cell('A1') to access cell A1's value.
Note: Actually, openpyxl uses sheet['A1'] or sheet.cell(row=1, column=1). Here, the blank expects cell and A1 for the exercise.
Fill all three blanks to create a dictionary of test data from Excel rows where column 1 is key and column 2 is value.
test_data = {row[[1]].value: row[[2]].value for row in sheet.iter_rows(min_row=2)}
print(test_data[[3]])Column 0 is the key, column 1 is the value in the dictionary comprehension.
To print a test username, use the key 'username'.