-2
Excelで列を開き、そのセルからすべての値をリストに移動しようとしています。'str'オブジェクトには属性がありません
builtins.AttributeError: 'str' object has no attribute 'columns'
しかし、私はすでに、同様にすべてを輸入しました:私はエラーを取得することを実行した後
def open_excel(col, excel_file):
open_file = openpyxl.load_workbook(excel_file)
sheet_object = open_file.get_sheet_names()[0]
cell_vals = []
col_num = column_index_from_string(start_col)
for cell in sheet_object.columns[col_num]:
cell_vals.append(str(cell.value))
。ここで
は、私がインポートしたものです:
import openpyxl
from openpyxl.cell import get_column_letter, column_index_from_string
import numpy as np
import matplotlib.pyplot as plt
ルック:
は、あなたがより簡単にして最初のアクティブな作業シートをつかむことができます:あなたは、実際のシートオブジェクトを取得するには、その名前を使用する必要があります属性.... 'print(type(sheet_object))' .... 'sheet_object'が定義された場所を見てください....デバッグが完了しました。 – miradulo