Hidden sheets in xlsx files

427 views
Skip to first unread message

Ron Garret

unread,
Aug 16, 2013, 5:55:52 PM8/16/13
to python...@googlegroups.com
Hidden sheets in xlsx files are not processed correctly in xlrd-0.9.2.  I think I know how to fix this, but before I take the time to produce a patch I thought I would ask:

1.  Has this problem already been fixed?

2.  If I fix it, where should I send the patch?

Thanks,
rg

John Machin

unread,
Aug 16, 2013, 8:40:29 PM8/16/13
to python...@googlegroups.com


On Saturday, August 17, 2013 7:55:52 AM UTC+10, Ron Garret wrote:
Hidden sheets in xlsx files are not processed correctly in xlrd-0.9.2.

Please be more specific than "not processed correctly". If possible attach a small xlsx file that exibits the alleged problem.

Ron Garret

unread,
Aug 27, 2013, 2:12:05 AM8/27/13
to python...@googlegroups.com
I've attached two files, one XLS which is processed correctly, and one XLSX which is not.  Each file contains two sheets, one visible, one not.  Here's the result:

>>> wb1 = xlrd.open_workbook('test.xls')
<xlrd.book.Book object at 0x10060d090>
>>> wb1.sheet_by_name('Sheet1').visibility
0
>>> wb1.sheet_by_name('Sheet2').visibility
1
>>> wb2 = xlrd.open_workbook('test.xlsx')
>>> wb2.sheet_by_name('Sheet1').visibility
True
>>> wb2.sheet_by_name('Sheet2').visibility
True

rg

test.xls
test.xlsx

John Machin

unread,
Aug 27, 2013, 8:10:59 AM8/27/13
to python...@googlegroups.com
Does you patch look something like this:

about line 389 in xlsx.py,
replace
     bk._sheet_visibility.append(True)
by
        state = elem.get('state')
        visibility_map = {
            None: 0,
            'visible': 0,
            'hidden': 1,
            'veryHidden': 2
            }
        bk._sheet_visibility.append(visibility_map[state])
?




On Saturday, August 17, 2013 7:55:52 AM UTC+10, Ron Garret wrote:

Ron Garret

unread,
Aug 27, 2013, 11:12:12 AM8/27/13
to python...@googlegroups.com
I hadn't written the patch yet, but if I had, yes, it would probably look an awful lot like that :-)

(In my xlrd it's line 366.  I have version 0.9.2.  Is that not the latest?)

rg

John Machin

unread,
Aug 27, 2013, 4:10:45 PM8/27/13
to python...@googlegroups.com


On Wednesday, August 28, 2013 1:12:12 AM UTC+10, Ron Garret wrote:
I hadn't written the patch yet, but if I had, yes, it would probably look an awful lot like that :-)

(In my xlrd it's line 366.  I have version 0.9.2.  Is that not the latest?)

My bad. 366 it is. I've committed that change to the xlrd  master branch at github.

Ron Garret

unread,
Aug 27, 2013, 7:51:22 PM8/27/13
to python...@googlegroups.com
Cool!  Thanks!
 
Reply all
Reply to author
Forward
0 new messages