weshatheleopard / rubyXL

Ruby lib for reading/writing/modifying .xlsx and .xlsm files
MIT License
1.28k stars 255 forks source link

Excel column formatting #261

Closed drthvdr closed 7 years ago

drthvdr commented 7 years ago

I was hoping to get some guidance on setting formats for entire columns as opposed to individual cells. Reason being: When you enter scientific notation, ex.: 3.2E+15, into an excel cell the default behavior converts it into integer notation. When I parse the data from excel, I'm expecting '3.2E+15' but instead I get 3200000000000000.

In order for excel to take scientific notation as is, the cell format needs to be Text (format: @). I'd like to be able to apply formatting to an entire column like you can do with changing column font, or width.

Thoughts?

weshatheleopard commented 7 years ago

In order to apply style to the column in rubyXL, you simply iterate through every cell in that column and apply the style to each cell (if it exists, of course). That's what Excel does.

"Column style" is simply a default that Excel uses when a new cell in that column is created, and that behavior is replicated by RubyXL