
Worksheet.rows 및 Worksheet.columns 프라퍼티로 셀 객체 얻기
만약 엑셀 파일 내 모든 행 (열 포함) 또는 모든 열(행 포함) 정보를 얻고자 한다면, Worksheet 클래스의 프라퍼티 rows 또는 columns을 사용한다.
rows :
Produces all cells in the worksheet, by row
columns :
Produces all cells in the worksheet, by column
임의 엑셀 파일에서 셀 값이 아래와 같이 입력되어 있다면,

Worksheet의 row 및 columns 프라퍼티를 사용하는 코드의 예는 다음과 같다.
# openpyxl 3.0.7
from openpyxl import load_workbook
workbook = load_workbook('sample.xlsx')
worksheet = workbook.active
print('max_row = ', worksheet.max_row)
print('max_col = ', worksheet.max_column)
print()
for cells in worksheet.rows:
for cell in cells:
print('{:2d}'.format(cell.value), end=' ')
print()
print()
for cells in worksheet.columns:
for cell in cells:
print('{:2d}'.format(cell.value), end=' ')
print()
아래의 실행 결과와 같이
Worsheet.rows 프라퍼티는 행을 기준으로 셀 객체를 포함하는 튜플을 반환하고,
Worksheet.columns 프라퍼티는 열을 기준으로 셀 객체를 포함하는 튜플을 반환한다.

Note :
For performance reasons the Worksheet.columns property is not available in read-only mode.