2017-03-28 1 views
-1
from openpyxl import * 
wb = load_workbook('excel.xlsx') 

table=[] 
Sheet_Name=wb.get_sheet_by_name('Input_Sheet') 
for Indx_row, row in enumerate(Sheet_Name.iter_rows()): 
    for cell_ind,cell in enumerate(row): 
     if Indx_row==0: 
      table.append(cell.value) 


print table 

Output:['Col1','Col2','Col3','Col4'] 

는 지금은 COL1, Col2의, 열 3, 엑셀 시트가 변경됩니다 동적 이후 python에서 openpyxl을 사용하여 엑셀 시트 열의 값을 다른 목록에 추가하는 방법은 무엇입니까?

Col1=[] 
Col2=[] 
Col3=[] 
Col4=[] 

Col4

같은 이름을 가진 상자 목록에합니다. 이제 해당 열 값을 해당 열 목록에 추가하고 싶습니다. 어떻게해야합니까?

답변

0

openpyxl은 iter_cols() 방법과 columns 속성을 제공합니다.

+0

내 질문을 편집했습니다. 나 한테 해결책을 제공해 줄 수 있겠 니? – user1681102

관련 문제