Text direction (right to left) in openpyxl

111 views Asked by At

I'd like to write Arabic text in a cell Each text is preceded by number when I run the code, the number appeared after text that due to the default text direction is left to right. could change text direction to be right to leftin certain cells?

enter image description here

change text direction to be right to left in certain cells

1

There are 1 answers

0
Charlie Clark On

Openpyxl implements the OOXML specification. It looks like the Alignment.readingOrder attribute is relevant here. This is defined as:

0 - Context Dependent - reading order is determined by scanning the text for the first non-whitespace character: if it is a strong right-to-left character, the reading order is right-to-left; otherwise, the reading order left-to-right.
1 - Left-to-Right- reading order is left-to-right in the cell, as in English.
2 - Right-to-Left - reading order is right-to-left in the cell, as in Hebrew.
The possible values for this attribute are defined by the W3C XML Schema unsignedInt datatype.```