Python Forum
Getting Cells from the Sheets "automate the boring stuff"
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Getting Cells from the Sheets "automate the boring stuff"
#5
I have tried it once more and got the following
>>> import openpyxl
>>> wb = openpyxl.load_workbook('Example_Page267.xlsx')
>>> sheet = wb.get_sheet_by_name('Sheet1')
>>> sheet['A1']
<Cell 'Sheet1'.A1>
>>> sheet['A1'].value
datetime.datetime(2015, 5, 4, 13, 34)
>>> c = sheet['B1']
>>> c.value
'Apples'
>>> 'Row ' + str(c.row) + ',Column ' + c.column + ' is ' + c.value
Traceback (most recent call last):
  File "<pyshell#38>", line 1, in <module>
    'Row ' + str(c.row) + ',Column ' + c.column + ' is ' + c.value
TypeError: can only concatenate str (not "int") to str
Reply


Messages In This Thread
RE: Getting Cells from the Sheets "automate the boring stuff" - by Shafla - Sep-23-2019, 09:02 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Lightbulb Help using Google Sheets matheuspimenta 0 741 Dec-15-2022, 05:36 PM
Last Post: matheuspimenta
  How to loop through all excel files and sheets in folder jadelola 1 4,574 Dec-01-2022, 06:12 PM
Last Post: deanhystad
  Openpyxl-change value of cells in column based on value that currently occupies cells phillipaj1391 5 9,944 Mar-30-2022, 11:05 PM
Last Post: Pedroski55
  Run the code for some stuff it does not return me why Anldra12 3 2,891 Apr-19-2021, 02:01 PM
Last Post: Anldra12
  How can I iterate through all cells in a column (with merge cells) with openpyxl? aquerci 1 7,556 Feb-11-2021, 09:31 PM
Last Post: nilamo
  "Automate the Boring Stuff with Python" creating a path works but only for CMD promt Milos 2 2,906 Nov-28-2020, 01:08 PM
Last Post: Larz60+
  Unable to print stuff from while loop Nick1507 4 2,387 Sep-17-2020, 02:26 PM
Last Post: Nick1507
  identical cells in 2 different excel sheets python pandas esso 0 1,661 Jul-19-2020, 07:50 PM
Last Post: esso
  Copy certain cells into new workbook certain cells Kristenl2784 4 2,520 Jul-14-2020, 07:59 PM
Last Post: Kristenl2784
  How Do I Install Stuff for Python? CopBlaster 6 3,254 May-08-2020, 12:27 PM
Last Post: hussainmujtaba

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020