Ana Nelson
unread,Mar 12, 2009, 7:56:19 AM3/12/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Python Ireland
First of all, thanks to everyone in Python Ireland for their
hospitality. :-)
I was asked last night for a specific example of something I had
changed to be more Rubyish. Probably the best example of this would be
the changes I made to the StyleFormat class.
In Surpass, you can set up a new StyleFormat by passing a hash of
format parameters to StyleFormat.new:
date_format = StyleFormat.new(:number_format_string => 'D-MMM-YY')
header_format = StyleFormat.new(:font_bold => true, :font_height
=> 230)
Then to use these style formats you would write to your worksheet like
this:
book = Workbook.new("style_formats.xls")
sheet = book.add_sheet
sheet.write(0, 0, "This is a date:", header_format)
sheet.write(1, 0, Date.new(2009, 1, 1), date_format)
book.save
The original way to accomplish this would be to set each attribute
individually, like so (in Python):
font0 = Font()
font0.height = 230
font0.bold = True
style0 = XFStyle()
style0.font = font0
Note that you can set individual attributes like this in Surpass
(Ruby) as well, but using a hash for initialization is a nice
shortcut.
I'll get my slides up ASAP.