From: Daniel B. <djb...@ya...> - 2004-07-05 03:37:26
|
--- David Brady <db...@sh...> wrote: > Date: Wed, 09 Jun 2004 22:18:30 -0600 > From: David Brady <db...@sh...> > To: djb...@ya... > Subject: rubyspreadsheet color/bg_color bugs? > --------------------------------- Hello, I just downloaded the rubyspreadsheet module, and am having difficultygetting the formatting to work--specifically with colors. I don't knowenough Ruby to know if this is specifically a problem withrubyspreadsheet, a problem originating in the perl module, or a problemwith me just not knwoing enough Ruby yet. I write code (mostly C++,PHP) for a living, and have been for 10+ years, but I've beenprogramming in Ruby for about 72 *hours* and as such, I am open to thepossibility that the problem may be on my end. :-) Specifically, some of the string colors don't seem to work--"brown" forexample does not work, and I could not get bg_color to work at all; butthe biggest trouble I ran into was in getting the numeric colors towork. E.g. f = Format.new( :color => 12 ) Should set the color to blue, but doesn't. The documentation says thatany number 8..63 is valid; in reality any integer value sets the colorto 0x7FFF (bad color value). A good code snippet is worth a thousand words, especially when theproblem may be with MY code, so here are some unit tests I have addedto tc_format.rb, and their results. I realize you're not made oftime... but if you get the chance, could you glance at these and tellme if I'm just up in the night? Each test is followed by its failuremessage in comments. Apologies if e-mail gibberizes the code.... I'dbe happy to send along the test file if you'd like, but I'm not willingto say "hi" and dump a file in your inbox in one go. :-) Thanks! -dB def test_color2 # from the documention: # Any integer from 8..63 is valid. 8.upto(63) { |c| @format.color = c assert_equal(c, @format.color,"Bad color value: numeric #{c}") } end # 2) Failure: # test_color2(TC_Format) # [tc_format.rb:94:in `test_color2' # tc_format.rb:92:in `upto' # tc_format.rb:92:in `test_color2']: # Bad color value: numeric 8. # <8> expected but was # <32767>. def test_color3 # from the documention: # The following strings are also recognized: # black, blue, brown, cyan, gray, green, lime, magenta, navy,orange, purple, # red, silver, white, yellow colors = %w(black blue brown cyan gray green lime magenta navyorange purple red silver white yellow) colors.each { |c| @format.color = c assert_not_equal(0x7FFF, @format.color, "Bad color value: string'#{c}'") } end # 3) Failure: # test_color3(TC_Format) # [tc_format.rb:106:in `test_color3' # tc_format.rb:104:in `each' # tc_format.rb:104:in `test_color3']: # Bad color value: string 'brown'. # <32767> expected to be != to # <32767>. def test_bg_color @format.bg_color = "blue" assert_equal(0x0C,@format.bg_color,"Bad color value") end # 1) Failure: # test_bg_color(TC_Format) [./tc_format.rb:112]: # Bad color value. # <12> expected but was # <"blue">. I wrote 2 more bg_color tests, and they do not fail--but this isclearly a problem with my unit test/Ruby knowledge. Se...@fo..._color = 12 *does* set the value to 12, but the cell does NOTcome out with a blue background. Setting @format.bg_color = "blue"passes my simple test of != 0x7FFF, but this is because it sets thebg_color to "blue"--i.e. Format#bg_color=() simply seems to be copyingthe parameter without any type of lookup or change. Thanks again for your time, -dB -- David Bra...@sh...I'm having a really surreal day... or AM I? __________________________________ Do you Yahoo!? New and Improved Yahoo! Mail - Send 10MB messages! http://promotions.yahoo.com/new_mail |