From: Daniel B. <djb...@ya...> - 2004-07-05 03:41:02
|
--- David Brady <db...@sh...> wrote: > Date: Tue, 15 Jun 2004 20:04:35 -0600 > From: David Brady <db...@sh...> > To: Daniel Berger <djb...@ya...> > Subject: Re: rubyspreadsheet color/bg_color bugs? > > Daniel, > > >># There's a bug in the loop--it destroys the > >>contents of cell_range[0]; > >> > >> > >Wait, are you saying there's a bug in my code or in > >your example? Your example looked correct to me as > >long as the range starts at 0. > > > In my example. My thinking is that merge_cells > should preserve the > contents of the first cell in the range. > Programmatically, it might > make sense to think of merging only the cells you > want to have > disappear, but intuitively what you do is select the > range of cells > (including the one whose contents will remain) and > then merge them into > a single cell. If I wanted to merge cells 5-8 on > row 3 into one cell, > this is what I would be thinking: > > workbook.write(3, 5, "My Column Group Heading") > workbook.merge_row_cells( 3, 5, 8 ) > > > >Hmm....I dunno if I wanna go down that path. Let > me > >think about it. I worry about overhead is all. > > > Yeah, if you're dealing with >7M files now and then, > efficiency will be > key, I think. I wonder how much of an > object-orientation can be > accomplished without sacrificing speed. Perhaps a > decorator pattern > could be used; you load up all the data into the > format it's already in > (or something equally fast) but it only behaves like > a Cell object when > accessed specially. > > Example: > > # ws = some worksheet > r = ws.row[3] > > Here, row[] would be a magic accessor that creates a > row object on the > fly and gives it access to the workbook data. The > row object then knows > how to perform operations on one row of the > workbook. Such as... > > cell = r.cell[3] > cell.write("I want a pony.") > > # -- or -- > > r.cell[0..4].each { |cell| > cell.set_bg('blue') > } > > # -- or -- > > r.merge_cells(5, 8) > > The advantage of this is, if you don't want to use > the OO paradigm, you > pay zero overhead for it. Just use the existing > accessor methods and > don't construct any objects. > > I notice that Ruby has some awesome overloading > abilities... is there a > way to overload Array() so that it (a) only accepts > objects of a given > type and (b) can have extra accessor methods added > to it? Example: > > > cells = r.cell[0..4] # cells is a cell > collection--an array of > worksheet cells > cells.merge() > > rows = ws.rows[5..8] > rows.set_format( Format.new( :bg_color='blue', > :color='white' ) ) > > ....etc. > > >Anyway, glad you're enjoying Ruby and I appreciate > the > >feedback. > > > Ditto! > > -dB > > -- > David Brady > db...@sh... > I'm having a really surreal day... or AM I? > > > __________________________________ Do you Yahoo!? Yahoo! Mail Address AutoComplete - You start. We finish. http://promotions.yahoo.com/new_mail |