rubyXL icon indicating copy to clipboard operation
rubyXL copied to clipboard

get_column_width_raw() handling default widths

Open caramdache opened this issue 4 years ago • 0 comments

I'm doing some pixel calculations using, so I use get_column_width_raw(). This works well, except for columns that have a defaut width. In this case, get_column_width_raw() returns null.

I've looked at the code for get_column_width(), it does handle default column widths, but not in pixel. Am I missing something? Is there any way for get_column_width_raw() to handle defaults widths? Would the following work?

def get_column_width_raw(column_index = 0)
  validate_workbook
  validate_nonnegative(column_index)

  range = cols.locate_range(column_index)
  if range
    range.width
  else
    RubyXL::ColumnRange::DEFAULT_WIDTH + 5.0 / RubyXL::Font::MAX_DIGIT_WIDTH
  end
end

caramdache avatar Sep 15 '20 16:09 caramdache