Following up on the previous lecture, in this lecture, we are going to see more sheet operations. And we are going to start with getting the value of a cell in a sheet by using the cell coordinates. First of all, we are referencing the same sheet from within the workbook, and that is employee data. And now in order to get the value of a particular cell, we will use sheet and in between square brackets and also in between quotes, let's enter the coordinates of that particular cell. So let's assume we want to get the value for cell B seven. And now after the square brackets, we are using the value attribute.
So dot value, and we have the value of the cell returns which is Anna. Let's check this. Indeed, the cell B seven has this value right here, which is Anna and this is correct. Another way to get the value of a sale in a sheet Using the coordinates of that cell is the following sheet, dot cell. And in between the parentheses of this method, we specify row equals, let's say six, comma column equals two. And again dot value.
Sorry, I entered the comma instead of a.so dot value. And this time we have Emily returned. So we are referencing row six and column two. That would be this cell right here basics, which is indeed, Emily. Okay. Now how can we reference a particular cell inside the sheet?
Well, that's pretty easy. Cell equals sheet, and in between square brackets, we enter the coordinates of the cell. So that would be let's say, B, nine, okay, and Enter. Now we can check several attributes for this cell, so cell, dot row, and of course We have row nine cell dot column. And that returns B, of course. And finally, cell dot coordinate, returns B nine, which is the full coordinate of this cell.
Okay, another set of information about the cells that we might need is the data type of the value inside the cell. And in order to get this data type, we are going to use cell dot data type. And we have s for string, because inside cell B nine, we have the first name of one of our employees, which is of course, a string. Now let's get back into the Python interpreter. And also we can check out the encoding format for a cell for the value inside the cell. So cell dot encoding, and that would be UTF eight, which is the default.
Also we can set a certain value for a cell. So first of all, I'm going to close this workbook to avoid any permission related issues, and I'm going to use Cell equals, let's say sheet of v2. And since we are working on column B, we will change the first name of one of our employees inside the workbook. So let's say cell dot value equals, and let's enter David for example. Okay. And of course, we should save our workbook.
So workbook dot Save, and the full path to the file. Now let's check our workbook once again. And indeed, we now have David in cell v2 inside our sheet, which is correct. The last thing I'll show you in this lecture is how to get the parent worksheet for a cell. So referring to our cell B two, let's find out the worksheet that is the parent of this cell by simply using the parent attributes or cell, not parent. And indeed, we have worksheet employee data returned.
Okay, I'll see you in the next lecture where we are going to talk about styles