在我的Excel文件中,单元格中的数据是缩进的,缩进信息非常重要。
我的代码:
import openxlpy as opxl
wb = opxl.load_workbool('file.xlsx')
sh = wb.get_active_sheet()
r = sh.rows
c = r[10][0]
现在的问题是: c.style.alignment给了我两个选项(1)缩进和(2)ident
(1)不返回正确的缩进信息 (2)具有正确的数字
两者有什么区别?身份是否正常以获得正确的信息。
谢谢
[更新]
openpyxl版本是1.8.5。文本表示树,每个缩进都是下一级。它从没有缩进开始,以1
的增量进行答案 0 :(得分:0)
我不知道您使用的是哪种版本的openpyxl,但ident
从未成为对齐属性。 c.alignment
是首选拼写。规范定义indent
因此:
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.