Книга: Automate the Boring Stuff with Python: Practical Programming for Total Beginners
Назад: 11. Web Scraping
Дальше: 13. Working with PDF and word Documents

and , respectively. Even if you already have .

. shows the tabs for the three default sheets named Sheet1, Sheet2, and Sheet3 that Excel automatically provides for new workbooks. (The number of default sheets created may vary between operating systems and spreadsheet programs.)

. (If you didn’t download example.xlsx from the website, you should enter this data into the sheet yourself.)

.

Specifying a column by letter can be tricky to program, especially because after column Z, the columns start by using two letters: AA, AB, AC, and so on. As an alternative, you can also get a cell using the sheet’s cell() method and passing integers for its row and column keyword arguments. The first row or column integer is 1, not 0. Continue the interactive shell example by entering the following:

. Its contents look like .

.

. shows what the spreadsheet looks like.

.

to review this style of import statement.)

Here’s an example that creates a new workbook and sets cell A1 to have a 24-point, italicized font. Enter the following into the interactive shell:

shows the possible keyword arguments for the Font() function.

.

.

.

.

shows which rows and columns will be frozen for some example settings of freeze_panes.

. Then enter the following into the interactive shell:

.

shows some sample coordinate arguments.