-1

When trying to read a number from the excel sheet I have, I'm getting the equation that resulted in that number. for example: The cell I'm trying to read calculates the sum of the 3 cells below it and gives the result of the summation. The problem is that I'm getting the equation of that sum operation instead of the actual result of the summation

Here is my python code:

from openpyxl import load_workbook

# Opening the excel sheet
workbook = load_workbook(filename="filename.xlsx")
sheet = workbook.active

# Printing out row 5 column 3 (or C5)
print(sheet.cell(row=5, column=3).value)

the output is:

=SUM(C6:C17)

but I want some integer instead like:

55

I just started so if there is any library that does that and it is better for manipulating excel sheets, let me know.

1 Answers1

0

I just found the answer from https://ehmatthes.github.io/pcc_2e/beyond_pcc/extracting_from_excel/

adding data_only=True to load_workbook(filename="filename.xlsx") will do the trick.

it should look like this:

workbook = load_workbook(filename="filename.xlsx", data_only=True)