Freeze Panes

1,489 views
Skip to first unread message

CJ

unread,
Jan 13, 2012, 3:20:40 PM1/13/12
to openpyxl-users
I'm having trouble using the 'freeze panes' functionality in openpyxl.
Has anybody gotten this to work. The snytax should be clear from the
source code but I can't get it to work. Thanks.

Cheers, CJ

Code Snippet:
from openpyxl.workbook import Workbook

ws = wb.create_sheet()
ws.freeze_panes == ws.cell('B11') #doesn't freeze panes
ws.freeze_panes == 'B11' #doesn't freeze panes

Anders Chrigstrom

unread,
Jan 15, 2012, 12:25:40 PM1/15/12
to openpyx...@googlegroups.com
On 2012-01-13 21:20, CJ wrote:
> I'm having trouble using the 'freeze panes' functionality in openpyxl.
> Has anybody gotten this to work. The snytax should be clear from the
> source code but I can't get it to work. Thanks.

Hi,

I implemented the 'freeze panes' functionality and i have no problems
using them aside from the fact that it is not supported when using
optimized_write though support for that is on my todo list.

>
> Cheers, CJ
>
> Code Snippet:
> from openpyxl.workbook import Workbook
>

You are missing the following line, right?
wb = Workbook()

> ws = wb.create_sheet()
> ws.freeze_panes == ws.cell('B11') #doesn't freeze panes
> ws.freeze_panes == 'B11' #doesn't freeze panes

Adding the following line:
wb.save('foo.xlsx')

I get a workbook with two worksheets and the second worksheet has frozen
panes. The first worksheet is the one You get when creating the workbook
and the second is from the call to create_sheet.

Regards,

/Anders C

CJ

unread,
Jan 18, 2012, 11:00:01 AM1/18/12
to openpyxl-users
Anders,

Thanks for your help. The code below works and requires '=' and not
'=='.

Cheers, CJ

from openpyxl.workbook import Workbook

wb = Workbook()
ws = wb.create_sheet()
ws.freeze_panes = ws.cell('B11')
wb.save('freezePane.xlsx')
Reply all
Reply to author
Forward
0 new messages