AtBS 12 Excel Flashcards
1
Q
How to import openpyxl?
A
import openpyxl
2
Q
How to load a workbook object in openpyxl?
A
WkbkObject = openpyxl.load_workbook (‘wkbk.xlsx’)
3
Q
How to get Excel tab names with openpyxl?
A
WkbkObject.sheetnames
4
Q
How to set a sheet object in openpyxl?
A
sheetname = WkbkObject[‘Sheet1’]
5
Q
How to get a cell value with openpyxl?
A
- Set Variable=Sheet[‘A1’]
2. type Variable.value into shell
6
Q
How to convert column letters in Excel
A
- From openpyxl.utils import get_column_letter, column_index_from_string
- get_column_letter(1) returns A or
- Column_index_from_string(‘A’) returns 1