module RubyXL::CellConvenienceMethods

Public Instance Methods

change_border(direction, weight) click to toggle source
# File lib/rubyXL/convenience_methods.rb, line 676
def change_border(direction, weight)
  validate_worksheet
  self.style_index = workbook.modify_border(self.style_index, direction, weight)
end
change_contents(data, formula_expression = nil) click to toggle source
# File lib/rubyXL/convenience_methods.rb, line 638
def change_contents(data, formula_expression = nil)
  validate_worksheet

  if formula_expression then
    self.datatype = nil
    self.formula = RubyXL::Formula.new(:expression => formula_expression)
  else
    self.datatype = case data
                    when Date, Numeric then nil
                    else RubyXL::DataType::RAW_STRING
                    end
  end

  data = workbook.date_to_num(data) if data.is_a?(Date)

  self.raw_value = data
end
change_horizontal_alignment(alignment = 'center') click to toggle source
# File lib/rubyXL/convenience_methods.rb, line 661
def change_horizontal_alignment(alignment = 'center')
  validate_worksheet
  self.style_index = workbook.modify_alignment(self.style_index) { |a| a.horizontal = alignment }
end
change_text_wrap(wrap = false) click to toggle source
# File lib/rubyXL/convenience_methods.rb, line 671
def change_text_wrap(wrap = false)
  validate_worksheet
  self.style_index = workbook.modify_alignment(self.style_index) { |a| a.wrap_text = wrap }
end
change_vertical_alignment(alignment = 'center') click to toggle source
# File lib/rubyXL/convenience_methods.rb, line 666
def change_vertical_alignment(alignment = 'center')
  validate_worksheet
  self.style_index = workbook.modify_alignment(self.style_index) { |a| a.vertical = alignment }
end
fill_color() click to toggle source
# File lib/rubyXL/convenience_methods.rb, line 716
def fill_color()
  validate_worksheet
  return workbook.get_fill_color(get_cell_xf)
end
font_color() click to toggle source
# File lib/rubyXL/convenience_methods.rb, line 711
def font_color()
  validate_worksheet
  get_cell_font.get_rgb_color || '000000'
end
font_name() click to toggle source
# File lib/rubyXL/convenience_methods.rb, line 701
def font_name()
  validate_worksheet
  get_cell_font.get_name
end
font_size() click to toggle source
# File lib/rubyXL/convenience_methods.rb, line 706
def font_size()
  validate_worksheet
  get_cell_font.get_size
end
get_border(direction) click to toggle source
# File lib/rubyXL/convenience_methods.rb, line 656
def get_border(direction)
  validate_worksheet
  get_cell_border.get_edge_style(direction)
end
horizontal_alignment() click to toggle source
# File lib/rubyXL/convenience_methods.rb, line 721
def horizontal_alignment()
  validate_worksheet
  xf_obj = get_cell_xf
  return nil if xf_obj.alignment.nil?
  xf_obj.alignment.horizontal
end
is_bolded() click to toggle source
# File lib/rubyXL/convenience_methods.rb, line 686
def is_bolded()
  validate_worksheet
  get_cell_font.is_bold
end
is_italicized() click to toggle source
# File lib/rubyXL/convenience_methods.rb, line 681
def is_italicized()
  validate_worksheet
  get_cell_font.is_italic
end
is_struckthrough() click to toggle source
# File lib/rubyXL/convenience_methods.rb, line 696
def is_struckthrough()
  validate_worksheet
  get_cell_font.is_strikethrough
end
is_underlined() click to toggle source
# File lib/rubyXL/convenience_methods.rb, line 691
def is_underlined()
  validate_worksheet
  get_cell_font.is_underlined
end
set_number_format(format_code) click to toggle source
# File lib/rubyXL/convenience_methods.rb, line 742
def set_number_format(format_code)
  new_xf = get_cell_xf.dup
  new_xf.num_fmt_id = workbook.stylesheet.register_number_format(format_code)
  new_xf.apply_number_format = true
  self.style_index = workbook.register_new_xf(new_xf)
end
text_wrap() click to toggle source
# File lib/rubyXL/convenience_methods.rb, line 735
def text_wrap()
  validate_worksheet
  xf_obj = get_cell_xf
  return nil if xf_obj.alignment.nil?
  xf_obj.alignment.wrap_text
end
vertical_alignment() click to toggle source
# File lib/rubyXL/convenience_methods.rb, line 728
def vertical_alignment()
  validate_worksheet
  xf_obj = get_cell_xf
  return nil if xf_obj.alignment.nil?
  xf_obj.alignment.vertical
end