Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
Anyone who has used Microsoft Excel to format cells will be familiar with the alignment settings in Microsoft Excel.
As you can see from the above figure, there are different kinds of alignment options:
All of these alignment settings are fully supported by Aspose.Cells for Python via .NET and are discussed in more detail below.
Aspose.Cells for Python via .NET provides a class, Workbook, that represents an Excel file. The Workbook class contains a worksheets collection that allows access to each worksheet in the Excel file. A worksheet is represented by the Worksheet class. The Worksheet class provides a cells collection. Each item in the cells collection represents an object of the Cell class.
Aspose.Cells for Python via .NET provides get_style and set_style methods for the Cell class that are used to get and set a cell’s formatting. The Style class provides useful properties for configuring alignment settings.
Select any text alignment type using the TextAlignmentType enumeration. The pre‑defined text alignment types in the TextAlignmentType enumeration are:
| Text Alignment Types | Description |
|---|---|
| GENERAL | Represents general text alignment |
| BOTTOM | Represents bottom text alignment |
| CENTER | Represents center text alignment |
| CENTER_ACROSS | Represents center across text alignment |
| DISTRIBUTED | Represents distributed text alignment |
| FILL | Represents fill text alignment |
| JUSTIFY | Represents justify text alignment |
| LEFT | Represents left text alignment |
| RIGHT | Represents right text alignment |
| TOP | Represents top text alignment |
| JUSTIFIED_LOW | Aligns the text with an adjusted kashida length for Arabic text |
| THAI_DISTRIBUTED | Distributes Thai text specially, because each character is treated as a word |
Use the Style object’s horizontal_alignment property to align the text horizontally.
Similar to horizontal alignment, use the Style object’s vertical_alignment property to align the text vertically.
It is possible to set the indentation level of the text in a cell with the Style object’s indent_level property.
Set the orientation (rotation) of the text in a cell with the Style object’s rotation_angle property.
The following section discusses how to control text by setting text wrapping, shrink‑to‑fit and other formatting options.
Wrapping text in a cell makes it easier to read: the height of the cell adjusts to fit all the text, instead of cutting it off or spilling over into adjacent cells. Set text wrapping on or off with the Style object’s is_text_wrapped property.
An alternative to wrapping text in a cell is to shrink the text size to fit the cell’s dimensions. This is done by setting the Style object’s is_shrink_to_fit property to true.
Like Microsoft Excel, Aspose.Cells for Python via .NET supports merging several cells into one. Aspose.Cells for Python via .NET provides two approaches to this task. One way is to call the cells collection’s merge method. The merge method takes the following parameters to merge the cells:
The other way is to first call the cells collection’s create_range method to create a range of the cells to be merged. The create_range method takes the same set of parameters as that of the merge method discussed above and returns a Range object. The Range object also provides a merge method that merges the range specified in the Range object.
It is possible to set the reading order of text in cells. The reading order is the visual order in which characters, words, etc. are displayed. For example, English is a left‑to‑right language while Arabic is a right‑to‑left language.
The reading order is set with the Style object’s text_direction property. Aspose.Cells for Python via .NET provides pre‑defined text direction types in the TextDirectionType enumeration.
| Text Direction Types | Description |
|---|---|
| CONTEXT | The reading order consistent with the language of the first entered character |
| LEFT_TO_RIGHT | Left to right reading order |
| RIGHT_TO_LEFT | Right to left reading order |
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.