Reading worksheets: Free Reading Comprehension Worksheets — Printable

Posted on

Browse Reading Worksheets & Printables

Skip to content

Our reading worksheets cover a variety of topics including alphabet and letter recognition, phonics, reading comprehension, sight words, vocabulary and emergent reader books. Hands-on activities will support your child and challenge him to solve puzzles, play bingo games, and word search.

Sort by

Alesia Netuk2022-12-23T17:16:47-05:00

Help your kindergartener build a strong reading comprehension skills. With this an word family story, she will read and spot some words.

Short Story. The Cat and the Rat.Alesia Netuk2022-12-23T17:16:47-05:00

Alesia Netuk2022-12-23T17:16:43-05:00

With this worksheet, kids learn to read, trace and build the word SET. Kids practice identifying the short medial vowel in the word and practice ET family words. Kids cut out cards and the bottom of the page and paste the letters to build a word.

Short Story. Dad and his pad.Alesia Netuk2022-12-23T17:16:43-05:00

Alesia Netuk2022-12-23T17:16:44-05:00

With this short ad word family story, children practice reading comprehension skills. Read, answer questions, glue the pictures… and more!

Short Story. Dan and his Van.Alesia Netuk2022-12-23T17:16:44-05:00

Alesia Netuk2022-12-23T16:46:10-05:00

In this non-fiction passage, students learn about the zebra. Where does the zebra live? What does it eat? How does it look like?

Zebra Reading PassageAlesia Netuk2022-12-23T16:46:10-05:00

Alesia Netuk2022-12-23T15:59:32-05:00

This worksheet introduces a child to sight word sentences that correlate with sight words she just learned. Pre-primer Dolch sight words reading practice set 1 includes words: the, to, and, a, I, you, it, in, said, for.

Sight Words Reading Practice | List 10Alesia Netuk2022-12-23T15:59:32-05:00

Alesia Netuk2022-12-23T17:16:52-05:00

Help your kindergartener get more confident with her reading skills. Word families encourage students to see letter-sound patterns.

Short Story. Where is my Ham?Alesia Netuk2022-12-23T17:16:52-05:00

Alesia Netuk2022-12-23T16:56:05-05:00

Students read all about the Life Cycle of a Chicken. They explore each stage in detail and connect it to the picture on aside. Great for your life cycle lesson.

All About Life Cycle of a Chicken for KidsAlesia Netuk2022-12-23T16:56:05-05:00

Alesia Netuk2022-12-23T16:33:26-05:00

This worksheet features pictures of things that begin with the letter A: angel, apple, alien, apron, alligator, acorn, astronaut, axe.

Things That Begin With The Letter AAlesia Netuk2022-12-23T16:33:26-05:00

Alesia Netuk2022-12-23T16:58:47-05:00

Students read the article and learn how turtle undergoes a complete metamorphosis. Students explore each stage of turtle life cycle and look at the pictures.

Turtle Life Cycle ArticleAlesia Netuk2022-12-23T16:58:47-05:00

Alesia Netuk2022-12-23T16:52:07-05:00

This worksheet introduces a child to sight word sentences that correlate with sight words she just learned. Pre-primer Dolch sight words reading practice set 4 includes words: here, help, make, yellow, two, play, run, find, three, funny.

Sight Words Reading Practice | List 5Alesia Netuk2022-12-23T16:52:07-05:00

Alesia Netuk2022-12-23T17:16:53-05:00

A short story for kindergarten kids to practice reading skills. The am word family story is designed to reinforce reading skills.

Short Story. Where is Sam?Alesia Netuk2022-12-23T17:16:53-05:00

Alesia Netuk2022-12-23T16:45:46-05:00

In this non-fiction passage, students learn about the penguin. Where does the penguin live? What does it eat? How does it look like?

Penguin Reading PassageAlesia Netuk2022-12-23T16:45:46-05:00

Alesia Netuk2022-12-23T15:59:35-05:00

With this reading worksheet, your child read sight word sentences that correlate with sight words she just learned. 1st Grade Dolch sight words reading practice set 11 includes words: were, them, ask, an, over, just, from, any, how, know.

Sight Words Reading Practice | List 12Alesia Netuk2022-12-23T15:59:35-05:00

Alesia Netuk2022-12-23T16:57:32-05:00

Students read the article and learn how ladybug undergoes a complete metamorphosis. Students explore each stage of ladybug life cycle and look at the pictures.

Ladybug Life Cycle ArticleAlesia Netuk2022-12-23T16:57:32-05:00

Alesia Netuk2022-12-23T17:13:59-05:00

This simple CVC word puzzle is excellent for learning to spell and reading in kindergarten. These puzzles are simple and easy for kids to use. They make great literary centers and fantastic for independent practice.

ED Word Family Reading WorksheetAlesia Netuk2022-12-23T17:13:59-05:00

Alesia Netuk2022-12-23T16:56:49-05:00

This butterfly lie cycle prompt encourages students to use the sequencing stages and arrange them into a writing. What was first, then, and after? What is the final transformation of the butterfly?

Frog Cycle | Reading Article for KidsAlesia Netuk2022-12-23T16:56:49-05:00

Alesia Netuk2022-12-23T15:59:33-05:00

With this reading worksheet, your child read sight word sentences that correlate with sight words she just learned. 1st Grade Dolch sight words reading practice set 10 includes words: of, his, had, him, her, some, as, then, could, when.

Sight Words Reading Practice | List 11Alesia Netuk2022-12-23T15:59:33-05:00

Alesia Netuk2022-12-23T16:55:43-05:00

Use the butterfly life cycle anchor chart in science centers, individual work, small group activities, and even more. You can download it in color or black and white versions.

Butterfly Life Cycle Article with PicturesAlesia Netuk2022-12-23T16:55:43-05:00

Alesia Netuk2022-12-23T16:28:59-05:00

Practice letter A or beginning sound A with cute pictures kids will reveal as they spin the wheel. This letter A spinner would be a great addition to your literacy centre.

Letter A Wheel SpinnerAlesia Netuk2022-12-23T16:28:59-05:00

Alesia Netuk2022-12-23T16:52:13-05:00

With this reading worksheet, your child read sight word sentences associated with sight words she just learned. Primer Dolch sight words reading practice set 7 includes words: like, this, will, yes, went, are, now, no, came, ride.

Sight Words Reading Practice | List 8Alesia Netuk2022-12-23T16:52:13-05:00

Alesia Netuk2022-12-23T16:33:27-05:00

This worksheet features pictures of things that begin with the letter B: barn, book, bed, bat, bee, baby, ball, bird.

Things That Begin With The Letter BAlesia Netuk2022-12-23T16:33:27-05:00

Alesia Netuk2022-12-23T17:05:10-05:00

What does an artist do? Free printable artist reading passage will help students practice their comprehension skills.

Artist – Reading PassageAlesia Netuk2022-12-23T17:05:10-05:00

Alesia Netuk2022-12-23T16:58:24-05:00

Students read the article and learn how shark undergoes a complete metamorphosis. Students explore each stage of shark life cycle and look at the pictures.

Shark Life Cycle ArticleAlesia Netuk2022-12-23T16:58:24-05:00

Alesia Netuk2022-12-23T16:45:04-05:00

In this non-fiction passage, students learn about the alligator. Where does the alligator live? What does it eat? How does it look like?

Alligator Reading PassageAlesia Netuk2022-12-23T16:45:04-05:00

Alesia Netuk2022-12-23T15:59:37-05:00

With this reading worksheet, your child read sight word sentences that correlate with sight words she just learned. 1st Grade Dolch sight words reading set 13 includes words: again, may, stop, fly, round, give, once, open, has, live, thank.

Sight Words Reading Practice | List 14Alesia Netuk2022-12-23T15:59:37-05:00

Alesia Netuk2022-12-23T17:14:31-05:00

This EN Word Family puzzle is excellent for learning to spell and reading in kindergarten. These puzzles are simple and easy for kids to use.

EN Word Family Reading WorksheetAlesia Netuk2022-12-23T17:14:31-05:00

Alesia Netuk2022-12-23T16:46:04-05:00

In this non-fiction passage, students learn about the whale. Where does the whale live? What does it eat? How does it look like?

Whale Reading PassageAlesia Netuk2022-12-23T16:46:04-05:00

Alesia Netuk2022-12-23T16:45:10-05:00

In this non-fiction passage, students learn about the cat. Where does the cat live? What does it eat? How does it look like?

Cat Reading PassageAlesia Netuk2022-12-23T16:45:10-05:00

Search Library

Search for:

By Resource

By Grade

By Subject

By Topic

Page load link

Go to Top

Reading Comprehension Worksheets


297 filtered results

Clear all filters

Hide done


With answer key

297 filtered results

Difficulty Level

  • Easy

  • Normal

  • Extra Challenge


  • Preschool

  • Kindergarten

  • Grade 1

  • Grade 2

  • Grade 3




Reading Comprehension Worksheets

Our Reading Comprehension Worksheets are perfect for young learners from Pre-K to Grade 3. By guiding students through the study of stories and narratives, our worksheets help to reinforce key comprehension skills, such as identifying main ideas, understanding details, inferring and synthesizing. Our worksheets will provide early readers with the practice they need to develop their comprehension skills, allowing them to read for informative pleasure. Our worksheets emphasize the importance of reading, provide activities that foster key reading skills, and can easily be incorporated into existing lesson plans. Get your little learners on the road to reading success today with our Reading Comprehension Worksheets!




Most Recent


Highest Rating



With answer key

Hide done

  • Reading Comprehension

Prometheus Story Worksheet

To understand a plot in fiction, kids must understand a story each step of the …

Grade 3
Reading Comprehension


The Lion and The Mouse Sequencing Worksheet

Read through The Lion and the Mouse sequencing worksheet and put your child’s reading comprehension …

Reading Comprehension


What Do You See? Reading Worksheet

New readers will love using the brilliantly colored and engaging pictures on this downloadable worksheet …

Reading Comprehension


Services Worksheet

In the community, people work at jobs that serve others and are considered services, as …

Grade 2
Reading Comprehension


Cause And Effect Worksheet

With this worksheet, you can help your kids understand better what cause and effects are.

Grade 3
Reading Comprehension


The Ugly Duckling / El Patito Feo Worksheet

Using the familiar and beloved story of The Ugly Duckling, students will find this adorable …

Grade 2
Reading Comprehension


Dinosaur Facts Worksheet

Improve your child’s reading skills with compelling nonfiction informational text that will keep your child …

Grade 3
Reading Comprehension


How the Moon Became Beautiful Worksheet

Fables are an incredible way for children to make real-world connections, and this Chinese fable …

Grade 1
Reading Comprehension


Skunks Worksheet

When we think of reading, we think of books, but there are so many informational …

Grade 1
Reading Comprehension


Author’s Purpose: Erosion Worksheet

By exposing your students to new texts and passages to read, you help them in …

Grade 2
Reading Comprehension


Point of View Worksheet

Point of View is important to readers who are trying to understand context and story …

Grade 1
Reading Comprehension


Sequence Word Eagle Worksheet

Sequence words help sew together our sentences and paragraphs in a way that allows others …

Grade 3
Reading Comprehension


Rhymes in Poems Worksheet

Poems are beautiful pieces of literature that can be in rhyming lines or unrhymed lines.

Grade 2
Reading Comprehension


White House Worksheet

When you read stories to your students, you encourage them to learn new words, as …

Grade 1
Reading Comprehension


The Crow and the Pitcher Worksheet

All stories have a lesson or message to share, and this is usually known as …

Grade 2
Reading Comprehension


Finding the Details and Connections: Assessment 2 Worksheet

How well does your child love animals? If you have pets at home, they will …

Reading Comprehension


“The Princess and the Pea” and “Cinderella” Worksheet

Read the story of Cinderella, and then the story of The Princess and the Pea …

Reading Comprehension


Descriptive Writing Worksheet: Part 1

Writing is an art, and writers often express their emotions through beautifully constructed sentences and …

Grade 2
Reading Comprehension


More About Dinosaurs Worksheet

Your little archaeologist will have a blast stomping into the past to learn more about …

Grade 3
Reading Comprehension


Robin Hood Folktale Worksheet

Put your child’s reading comprehension to the test with this Robin Hood folktale worksheet! Kids …

Grade 3
Reading Comprehension


Baa Baa Black Sheep Printable

Jumpstart your little reader’s budding comprehension skills with this Baa Baa Black Sheep printable worksheet! …

Reading Comprehension


Volcano Facts Worksheet

Use this volcano facts worksheet for 3rd grade to increase the skills needed for both …

Grade 3
Reading Comprehension


Jamestown Worksheet

You can help your kids build their vocabulary by reading some simple texts and short …

Grade 3
Reading Comprehension


Sequence: Jack and The Beanstalk Worksheet

Before beginning this worksheet, make sure that your little ones are already familiar with the …

Grade 2
Reading Comprehension





. ..


Try Kids Academy for FREE! 

See full Learning Program

Yes, I want to add
— the brick-compatible construction set for building 3D circuits with lights, sounds, motion, and other.


Gift card
Enter coupon code

Note: You will not be billed until your free trial has ended and can cancel at any time. No strings attached.

Great app!

This app is wonderful for my 7 years old son! 🙂 It focuses on basic reading, writing, and math skills. The reward system is great and consistent!


Daughter’s favorite

Still a top favorite for our 7 year old. She loves earning her stars as she learns to trace letters and numbers. Coloring and the sounds are engaging and are on target for her age group and being Pre K.


Great app

Wow! This app is really great. For the first time my kids actually enjoy learning math and reading. The games on Kids Academy are educational and really fun.


Such a great app!

This was a really fun way to get my kids to practice their math. I usually struggle to get them into it and Kids Academy makes it easy.

Fernanndas Stoun

So engaging

We love how we can focus on math with this app. It is engaging and we love how we are able to adjust and tailor the levels according to our son’s knowledge and skill levels!

Momma Anna

Great for kids

Our 7 years old daughter loves reading activities and every off-line game Kids Academy offers. This is a very good app, I highly recommend it!


Reading Worksheet Phonetics Textbook, Checked Flag Icon, angle, rectangle, reading png

Reading Worksheet Phonetics Textbook, Checked checkbox icon, angle, rectangle, reading png


  • angle,
  • rectangle,
  • reading,
  • symmetry,
  • monochrome,
  • black,
  • teacher,
  • experience,
  • phonetics,
  • area,
  • rest,
  • skill,
  • monochrome photography,
  • line,
  • training,
  • information,
  • checkered flag badge,
  • black and white,
  • worksheet,
  • png,
  • transparent,
  • free download

About this PNG

Image size


File size


MIME type


Download PNG ( 63. 57KB )

resize PNG




Non-Commercial Use, DMCA Contact Us

  • Formula One racing flags Drapeau xe0 damier Auto racing, checkered flag, flag, racing, symmetry png

  • Car Auto racing Racing flags, Checkered Border s, white, flag, rectangle png

  • Laurel wreath Olive wreath, checkered flag, leaf, monochrome, royalty Free png

  • black and white frame, white frame, angle, rectangle, symmetry png

  • org/ImageObject»>

    black and white checkered racing flag, Flag of the United States Flag of the United States Drawing, checkered flag, miscellaneous, white, flag png

  • Electronic signature, signature, miscellaneous, angle, white png

  • bubble illustration, Water Drop, drops, angle, white, text png

  • Racing flags Drapeau à damier, Flag, miscellaneous, angle, flag png

  • two black and white checkered flags, Racing flags, Creative black and white checkered flag, miscellaneous, white, flag png

  • org/ImageObject»>

    black and gray flag illustration, Racing flags Auto racing, FLAG RACE, angle, white, flag png

  • Flag, checkered flag, template, angle, flag png

  • Essay Learning English, english, people, reading, toddler png

  • Line Symmetry Point Geometric abstraction, Abstract geometric lines, angle, white, rectangle png

  • Arrow Drawing, arrow loops, angle, leaf, text png

  • Spider web Drawing, cobweb, angle, white, leaf png
    76. 51KB

  • Clock face Digital clock Time, clock, template, angle, white png

  • Star Black and white, star, angle, white, leaf png

  • two black and white checkered flags, Formula One race track Racing flags Auto racing Dirt track racing track, Black Checkered Flag, miscellaneous, flag, black Hair png

  • Shield Shape, shield, angle, rectangle, triangle png

  • flying black birds illustration, Bird flock, Birds, angle, white, animals png

  • org/ImageObject»>

    square frame symbol, frame Icon, square frame, frame, angle, white png

  • square black line illustration, Paper .br Page Teacher Educator, dotted frame, border, angle, white png

  • Black and white Icon, Gradient lines can adjust brushes, texture, angle, ink png

  • Computer Icons Racing flags, checkered flag, angle, flag, text png

  • Banner Ribbon, doodle, angle, flag, rectangle png

  • rectangular black frame, Black and white Angle Point Line, Cute borders, white, text, rectangle png
    14. 43KB

  • WhatsApp iPhone, whatsapp, logo, monochrome, black png

  • Film strip Cinema, cinema film, white, rectangle, monochrome png

  • Black and white Square, paper shadow projection angle, texture, angle, white png

  • Computer Icons Book, book, angle, rectangle, reading png

  • Water Drop Icon, Summer rain, water drop, texture, angle, white png

  • black WhatsApp logo, WhatsApp Computer Icons, whatsapp, logo, monochrome, black png
    24. 25KB

  • White Black Pattern, shadow angle, texture, angle, rectangle png

  • black and white illustration, Border Frames and Frames, black frame, angle, white, leaf png

  • Black and white Pattern, Geometric abstract perspective blocks, blue mirror illustration, texture, angle, white png

  • Speech balloon Comic book Template, BICBLE, miscellaneous, angle, text png

  • black polka dots, Polka dot Pattern, Black polka dots, angle, white, rectangle png
    228. 94KB

  • four black arrows, Arrow, Arrow Sketch, angle, white, face png

  • white black pattern, frame silhouette frame cartoon, white paper square, white picture frame, texture, angle, white png

  • Black and white Fog, Grayscale, texture, angle, white png

  • White Pattern, paper shadow projection angle, angle, rectangle, monochrome png

  • Spider-Man Drawing, spider web, web illustration, angle, leaf, heroes png

  • org/ImageObject»>

    White flag Wait, White flag, raised the white flag, miscellaneous, angle, white png

  • Monochrome Drawing, white line, texture, angle, white png

  • Racing flags, Flag, miscellaneous, flag, racing png

  • black frame, Borders and Frames, Simple frame, border, white, mammal png

  • checkered pattern illustration, Flag Euclidean, Black and white checkered flag, angle, white, flag png

  • black and white checkered illustration, Formula One racing flags Sport White flag, Black and white checkered flag, miscellaneous, flag, rectangle png
    48. 46KB

  • black stripes, Black and white Monochrome, stripe, angle, text, rectangle png

  • Smoke, smoke smoke, texture, white, smoke png

Python openpyxl module, working with XLSX files

Excel spreadsheets are an intuitive and convenient way to manipulate large datasets without any technical background. Therefore, this is one of the formats that, at some point in time, you will have to deal with. Often there will be tasks to extract some data from a database or log file into an Excel spreadsheet, or vice versa, convert an Excel spreadsheet into some more convenient program form, there are a lot of examples of this.

openpyxl module is a Python library for reading/writing Office Open XML formats (Excel 2010 files) with extensions xlsx / xlsm / xltx / xltm .

Installing the

openpyxl module in the virtual environment.

The openpyxl module is hosted on PyPI, so installation is relatively easy.

 # create a virtual environment if not
$ python3 -m venv .venv --prompt VirtualEnv
# activate the virtual environment
$ source .venv/bin/activate
# install the openpyxl module
(VirtualEnv):~$ python3 -m pip install -U openpyxl

Basics of working with Microsoft Excel files in Python.

  • Create an Excel workbook.
    • New Excel worksheet.
    • Copy an Excel worksheet.
    • Deleting an Excel worksheet.
  • Access to a spreadsheet cell and its value.
  • Access to a range of cells in a spreadsheet sheet.
  • Get only sheet cell values.
  • Adding data to cells in a list.
  • Save the created workbook to an Excel file.
    • Save book data as a stream.
  • Loading an XLSX document from a file.

Create an Excel workbook.

To get started with the openpyxl module , there is no need to create a spreadsheet file in the file system. You just need to import the class Workbook and instantiate it. A workbook is always created with at least one worksheet, it can be retrieved using property :

 >>> from openpyxl import Workbook
# create a book
>>> wb = Workbook()
# make the only sheet active
A new Excel worksheet.

New worksheets can be created using the Workbook.create_sheet() method :

 # insert worksheet at the end (default)
>>> ws1 = wb.create_sheet("Mysheet")
# insert worksheet at first position
>>> ws2 = wb.create_sheet("Mysheet", 0)
# insert the worksheet at penultimate position
>>> ws3 = wb.create_sheet("Mysheet", -1)

Sheets are automatically named when they are created. They are numbered sequentially (Sheet, Sheet1, Sheet2, . ..). These names can be changed at any time using the property Worksheet.title :

 >>> ws.title = "NewPage"

The background color of the tab with this title is white by default. You can change this color by specifying color code RRGGBB for sheet attribute Worksheet.sheet_properties.tabColor :

 >>> ws.sheet_properties.tabColor = "1072BA"

The worksheet can be retrieved by using its name as the instance key of the created Excel workbook:

 >>> ws3 = wb["NewPage"]

To view the names of all worksheets in a workbook, use the attribute Workbook.sheetname . You can also iterate through the worksheets of an Excel workbook.

 >>> wb.sheetnames
# ['Mysheet1', 'NewPage', 'Mysheet2', 'Mysheet']
>>> for sheet in wb:
Copying an Excel worksheet.

To create a copy of worksheets in one workbook, you must use the method Workbook. copy_worksheet() :

 >>> source_page =
>>> target_page = wb.copy_worksheet(source_page)

Note . Only cells (values, styles, hyperlinks, and comments) and certain worksheet attributes (sizes, format, and properties) are copied. All other book/sheet attributes are not copied, such as images or charts.

Ability to copy worksheets between workbooks is supported. You cannot copy a worksheet if the workbook is open in read-only or write-only mode.

Deleting an Excel worksheet.

Obviously, there is a need to delete a spreadsheet sheet that already exists. Module openpyxl makes it possible to delete a sheet by its name. Therefore, you first need to find out which sheets are present in the book, and then delete the unnecessary one. Method 9 is responsible for deleting the sheets of the book0183 Workbook.remove() .

Look at the example:

 # find out if the sheet names are present in the book
>>> name_list = wb. sheetnames
>>> name_list
# ['Mysheet1', 'NewPage', 'Mysheet2', 'Mysheet', 'Mysheet1 Copy']
# let's say we don't need the first and last
# delete the first sheet by its name with a check
# the existence of such a name in the book
>>> if 'Mysheet1' in wb.sheetnames:
        # If a sheet named `Mysheet1` is present
        # in the list of sheets of the book instance, then delete
>>> wb.sheetnames
# ['NewPage', 'Mysheet2', 'Mysheet', 'Mysheet1 Copy']
# delete the last sheet through the operator
# `del`, extract the sheet name by index
# of the resulting list `name_list`
>>> del wb[name_list[-1]]
>>> wb.sheetnames
# ['NewPage', 'Mysheet2', 'Mysheet']

Access to a cell and its value.

Once the worksheet is selected, you can start modifying the contents of the cells. Cells can be accessed directly as worksheet keys, for example ws['A4'] . This will return the cell at A4 or create it if it doesn’t already exist. Values ​​can be assigned directly:

 >>> ws['A4'] = 5
>>> ws['A4'].value
# 5
>>> ws['A4'].column
# 1
>>> ws['A4'].row
# 4

If the cell object is assigned to a variable, then this variable can also be assigned a value:

 >>> c = ws['A4']
>>> c.value = c.value * 2
>>> c.value
# 10

There is also a method Worksheet.cell() . It provides access to cells by directly specifying row and column values:

 >>> d = ws.cell(row=4, column=2, value=10)
>>> d
>>> d.value = 3.14
>>> print(d. value)
# 3.14

Note . When you create a worksheet in memory, it does not contain cells. Cells are created the first time they are accessed.

Important ! Because of this behavior, simply iterating over cells in a loop will create objects of those cells in memory even if no value is assigned to them.

Don’t run this example, take my word for it:

 # will create 100x100=10000 empty objects in memory
# cells, just using up RAM. 
>>> for x in range(1,101):
... for y in range(1,101):, column=y)

Access to a range of cells in a spreadsheet sheet.

A range with cells in the active sheet of a spreadsheet can be obtained using simple slicing. These slices will return iterators of cell objects.

 >>> cell_range = ws['A1':'C2']
>>> cell_range
# ((, , ),
# (, , ))

Similarly, you can get the ranges of existing rows or columns on a sheet:

 # All available cells in column `C`
>>> colC = ws['C']
# All available cells in column range `C:D`
>>> col_range = ws['C:D']
# All available cells in row 10
>>> row10 = ws[10]
# All available cells in row range `5:10`
>>> row_range = ws[5:10]

You can also use the Worksheet.iter_rows() method:

 >>> for row in ws.iter_rows(min_row=1, max_col=3, max_row=2):
... for cell in row:
. ..print(cell)

Similarly, the Worksheet.iter_cols() method will return columns:
… for cell in col:

Note . For performance reasons, the Worksheet.iter_cols() method is not available in read-only mode.

If you want to loop through all the rows or columns of a file, you can use the property Worksheet.rows :

 >>> ws =
>>> ws['C9'] = 'hello world'
>>> tuple(ws.rows)
# ((, , ),
# (, , ),
# (, , ),
# ...
# (, , ),
# (, , ),
# ( A9>, , ))

or property Worksheet.columns :

 >>> tuple(ws.columns)
# ((,
# ,
# ...
# ,
# ),
# (,
# ,
# ...
# ,
# ))

Note . For performance reasons, property Worksheet.columns is not available in read-only mode.

Get only cell values ​​of the active sheet.

If you just need the values ​​from the worksheet, you can use the active worksheet property Worksheet.values ​​ . This property loops through all the rows in the sheet, but only returns cell values:

 for row in ws.values:
   for value in row:

To return only the value of a cell, the Worksheet.iter_rows() and Worksheet.iter_cols() methods above can take an argument of values_only :

 >>> for row in ws. iter_rows(min_row=1, max_col=3, max_row=2, values_only=True):
# (None, None, None)
# (None, None, None)

Adding data to worksheet cells as a list.

The openpyxl module makes it super easy and convenient to add data to the end of a spreadsheet sheet. This convenience is provided by the worksheet object method Worksheet.append(iterable) , where the argument iterable is any iterable object (list, tuple, etc.). This behavior allows, without crutches, to transfer data from other sources into a spreadsheet, such as CSV files, database tables, data frames from Pandas, etc.

Method Worksheet.append() adds a group of values ​​to the last row that does not contain data.

  • If it is a list: all values ​​are added in order, starting from the first column.
  • If this is a dictionary: values ​​are assigned to columns designated by keys (numbers or letters).

Use Cases0005 append dictionary:

  • option 1: . append({'A' : 'cell A1', 'C' : 'cell C1'}) , using column letters as keys.
  • option 2: .append({1 : 'cell A1', 3 : 'cell C1'}) , using column numbers as keys.

Example of adding data from the list:

 # existing workbook sheets
>>> wb.sheetnames
# ['NewPage', 'Mysheet2', 'Mysheet']
# add data to a sheet named `Mysheet2`
>>> ws = wb["Mysheet2"]
# create arbitrary data using
# nested list generator
>>> data = [[row*col for col in range(1, 10)] for row in range(1, 31)]
>>> data
# [1, 2, 3, 4, 5, 6, 7, 8, 9],
# [2, 4, 6, 8, 10, 12, 14, 16, 18],
# ...
# ...
# [30, 60, 90, 120, 150, 180, 210, 240, 270]
# add data to the selected sheet
>>> for row in data:
... ws.append(row)

That's it, data added... Simple? Not easy, super easy!

Save the created workbook to an Excel file.

The easiest and safest way to save a workbook is to use the method of the Workbook object :

 >>> wb = Workbook()
>>> wb. save('test.xlsx')

Attention . This operation will overwrite the existing file without warning!!!

After saving, you can open the resulting file in Excel and view the data by selecting the sheet named NewPage .

Note . The filename extension does not have to be xlsx or xlsm , although you may have problems opening it directly in another application. Since OOXML files are mostly ZIP files, you can also open them with your favorite ZIP archive manager.

Save book data as a stream.

If you need to save a file to a stream, for example when using a web application such as Flask or Django, you can simply provide tempfile.NamedTemporaryFile()
from openpyxl import Workbook
wb = workbook()
with NamedTemporaryFile() as tmp:
stream =

Attribute can be specified template=True to save the workbook as a template:

 >>> from openpyxl import load_workbook
>>> wb = load_workbook('test. xlsx')
>>> wb.template = True

Note . Attribute wb.template defaults to False , which means save as a document.

Attention . The following will fail:

 >>> from openpyxl import load_workbook
>>> wb = load_workbook('test.xlsx')
# Must be saved with *.xlsx extension
>>>'new_test.xlsm') # MS Excel cannot open document
# You need to specify the attribute `keep_vba=True`
>>> wb = load_workbook('test.xlsm')
>>> wb = load_workbook('test.xltm', keep_vba=True)
# If you need a document template, you must specify the *.xltm extension.
>>>'new_test.xlsm') # MS Excel cannot open document

Loading an XLSX document from a file.

To open an existing Excel workbook, you must use the openpyxl.load_workbook() function :

 >>> from openpyxl import load_workbook
>>> wb2 = load_workbook('test.xlsx')
>>> print(wb2.

By alexxlab

Similar Posts