Setting the height and width of cell in Python for Data Science:
The worksheet objects have row_dimension and column_dimension, which are attributes controlling row heights and column widths. The row_dimensions and the column_dimension of a sheet are similar to values in a dictionary. The row_dimensions contain RowDimension objects and column_dimensions contain ColumnDimension objects. When we use row_dimension, we can access one of the objects using number of rows. In case of column_dimensions, we are able to access one of the objects using letters of the column.
Code 1: Setting the dimensions of the cell
Merging of cells:
We can merge rectangular area of cells into a single cell by using merge_cells() sheet method. The argument used for merging the cells is a single string of the top left and bottom right cells present in the rectangular area to be merged.
Code 2: Merging of cells
Unmerging of cells:
In case we need to unmerge the cells, we can call unmerge_cells() sheet method.
Code 3: Unmerging of cells
Setting the font styles of cells:
For customizing font styles in cells, we need to import the Font() function from the openpyxl.styles module.
Code 4: Setting font of text