Search code examples
ruby-on-railsrubyspreadsheetrubyxl

Auto resizing of the font on RubyXL


I'm currently working on the ruby on rails project which handles excel sheets.

I'm using RubyXL for it.

https://github.com/weshatheleopard/rubyXL

What I have no idea about it is how to shrink the texts to fit the cell.

I believe that this shrinkToFitenter image description here

will make it possible.

But I don't know how to call it.

Would anyone help me with this please?

Thank you so much for reading :)


Solution

  • module RubyXL
        module CellConvenienceMethods
            def change_shrink_to_fix(shrink_to_fit = false)
                validate_worksheet
                self.style_index = workbook.modify_alignment(self.style_index) { |a| a.shrink_to_fit = shrink_to_fit }
            end
        end
    end