Method: Axlsx::Worksheet#column_widths
- Defined in:
- lib/axlsx/workbook/worksheet/worksheet.rb
#column_widths(*args) ⇒ Object
Note:
For updating only a single column it is probably easier to just set ws.auto_fit_data[:fixed] directly
This is a helper method that Lets you specify a fixed width for multiple columns in a worksheet in one go. Axlsx is sparse, so if you have not set data for a column, you cannot set the width. Setting a fixed column width to nil will revert the behaviour back to calculating the width for you.
343 344 345 346 347 348 349 |
# File 'lib/axlsx/workbook/worksheet/worksheet.rb', line 343 def column_widths(*args) args.each_with_index do |value, index| raise ArgumentError, "Invalid column specification" unless index < @column_info.size Axlsx::validate_unsigned_numeric(value) unless value == nil @column_info[index].width = value end end |