In Python 3.x, print
should be used as function form.
print(sheet_ranges.cell('A14').value)
# ^ ^
Question
I'm using openpyxl 1.7.0 with python 3.3. I have used Excel 2007 and 2010 with the code
I created a basic excel 2007 workbook with cells A1-A21 filled with a random number in each one to test the code on their website. I saved the excel sheet as "thetest". The sheet that the numbers are on is called Sheet1. This is the code I ran.
from openpyxl import load_workbook
wb = load_workbook(filename = r'thetest.xlsx')
sheet_ranges = wb.get_sheet_by_name(name = 'Sheet1')
print sheet_ranges.cell('A14').value
I ran this code and got a message that highlighted the second "sheet_ranges" that has .cell after it and said invalid syntax. What is going on with this? Are there any good tutotrials for using this module as well?
Solution
In Python 3.x, print
should be used as function form.
print(sheet_ranges.cell('A14').value)
# ^ ^