Using Indent Level

282 views
Skip to first unread message

Dan K

unread,
May 16, 2012, 5:55:44 PM5/16/12
to python-excel
I am trying to use xlrd to read in rows from an excel file. I need to
process the row differently based on the indentation level of the
first cell in the row. The cells do not have any spaces in the values.
In other words, len(cell.value) - len(cell.value.lstrip()) == 0. But
the text appears indented when you view the spreadsheet. My only other
thought was that they had an indent level. However, when I try
wb.xf_list[cell.xf_index].alignment.indent_level, I get 0 for every
row. My workbook is opened by wb =
open_workbook(input_file,formatting_info=True) so I know the
formatting info should be populated (and actually text justification
seems to be returning fine, just not indents). Any ideas as to why it
would be returning 0, even though the cells clearly have an indent
level?

Thanks!

John Machin

unread,
May 16, 2012, 8:11:05 PM5/16/12
to python...@googlegroups.com


On Thursday, May 17, 2012 7:55:44 AM UTC+10, Dan K wrote:
I am trying to use xlrd to read in rows from an excel file. I need to
process the row differently based on the indentation level of the
first cell in the row. The cells do not have any spaces in the values.
In other words, len(cell.value) - len(cell.value.lstrip()) == 0. But
the text appears indented when you view the spreadsheet. My only other
thought was that they had an indent level. However, when I try
wb.xf_list[cell.xf_index].alignment.indent_level, I get 0 for every
row.

Maybe the horizontal alignment is not "left". What is the value of alignment,hor_align (0 is left)?

Another possibility: Check for a custom "number format". A format string containing "yadda"@ will cause cell contents of qwerty to be displayed as yaddaqwerty ... replace yadda with spaces and it will look like left-indented.
Reply all
Reply to author
Forward
0 new messages