rubyXL icon indicating copy to clipboard operation
rubyXL copied to clipboard

implement support to change format of a cell

Open fera2k opened this issue 7 years ago • 4 comments

Hi.

Great gem! I just used it on a small project I'm working on. Thanks!

I'd like to suggest to implement a method on Cell class to allow to change a format the cell after it has been created.

Something like this:

cell = worksheet.add_cell(0, 0, "100") # created using string format
cell.change_format(:number)  #force change to number 

I could try to work on this code. Would you be interested in pull request with this feature ?

fera2k avatar May 10 '18 19:05 fera2k

The problem here is coming up with the API. You do realize that there's a wide variety of possible number and date/time formats, right? (And those listed are only a pre-selected fraction of what is possible at all).

weshatheleopard avatar May 10 '18 20:05 weshatheleopard

Thanks for replying. I think this fraction of possible formats should be good for start.

Maybe you could have methods to change it to the primitive formats:

  • General
  • Number
  • Currency
  • Date
  • Time
  • Percentage
  • Text

fera2k avatar May 14 '18 14:05 fera2k

why not. May be better to replace "General" with "Raw"

tracyloisel avatar Sep 04 '19 15:09 tracyloisel

Maybe even better. Make something just like when you paste something to excel that it doesn't ask you, it "magically" guess the format. Would be nice to have something similar. I stumble upon a problem to generate a table with several different kinds, but all strings on Ruby and I'm struggling to identify and format percentage numbers.

bonafernando avatar Dec 15 '20 02:12 bonafernando