openpyxl alignment indent vs ident

2.2k views Asked by At

In my Excel file data in the cell is indented, and indent information is very important to get.

My code:

import openxlpy as opxl

wb = opxl.load_workbool('file.xlsx')
sh = wb.get_active_sheet()
r = sh.rows
c = r[10][0]

now the question: c.style.alignment gives me two options (1) indent and (2) ident

(1) does NOT return correct indent information (2) has correct number

what is the difference between the two? Is it normal for ident to have correct info.

thank you

[update]

openpyxl version is 1.8.5. Text is representing a tree, where each indent is next level. It starts with no indents and goes in increments of 1

1

There are 1 answers

2
Charlie Clark On

I don't know what version of openpyxl you're using but ident has never been an alignment attribute. c.alignment is the preferred spelling. The specification defines indent thus:

An integer value, where an increment of 1 represents 3 spaces. Indicates the number of spaces (of the normal style font) of indentation for text in a cell. The number of spaces to indent is calculated as following:
Number of spaces to indent = indent value * 3
[Example:For example, an indent value of 1 means that the text begins 3 space widths (of the normal style font) from the edge of the cell.
end example]
[Note: The width of one space character is defined by the font. end note] Only left, right, and distributed horizontal alignments are supported.
The possible values for this attribute are defined by the W3C XML Schema unsignedInt datatype.