I am trying to read excel which is formulated means some values in excel is driven from formula I have tried two approach but I don’t receive any value. I get ‘None’. Can someone of you review my code and help me please?
I have tried two approaches and no clue. I wish to read data in same way as shown in excel
def clean_data_from_excel(self,file_path)
# Load the workbook and select the sheet
wb = openpyxl.load_workbook(file_path,data_only=True)
sheet = wb['ABC']
row_num = sheet.max_row # Number of rows
col_num = sheet.max_column # Number of columns
all_rows = []
# Loop through rows and columns
for row in range(2, row_num + 1): # Skip header row
row_values = {}
for column in range(1, col_num + 1):
# Get cell element
cell = sheet.cell(row=row, column=column)
header = sheet.cell(row=1, column=column).value # Get header for keys
row_values[header] = cell.value # Store value exactly as it is in the cell
if row_values:
all_rows.append(row_values)
return all_rows