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:
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 theFont()
function.freeze_panes
.You can write this program by using nested for
loops to read in the spreadsheet’s data into a list of lists data structure. This data structure could have sheetData[x][y]
for the cell at column x
and row y
. Then, when writing out the new spreadsheet, use sheetData[y][x]
for the cell at column x
and row y
.
Write a program to read in the contents of several text files (you can make the text files yourself) and insert those contents into a spreadsheet, with one line of text per row. The lines of the first text file will be in the cells of column A, the lines of the second text file will be in the cells of column B, and so on.
Use the readlines() File
object method to return a list of strings, one string per line in the file. For the first file, output the first line to column 1, row 1. The second line should be written to column 1, row 2, and so on. The next file that is read with readlines()
will be written to column 2, the next file to column 3, and so on.