Module: RubyXL::CellConvenienceMethods

Included in:
Cell
Defined in:
lib/rubyXL/convenience_methods.rb

Instance Method Summary collapse

Instance Method Details

#change_border(direction, weight) ⇒ Object



615
616
617
618
# File 'lib/rubyXL/convenience_methods.rb', line 615

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) ⇒ Object



577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
# File 'lib/rubyXL/convenience_methods.rb', line 577

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') ⇒ Object



600
601
602
603
# File 'lib/rubyXL/convenience_methods.rb', line 600

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) ⇒ Object



610
611
612
613
# File 'lib/rubyXL/convenience_methods.rb', line 610

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') ⇒ Object



605
606
607
608
# File 'lib/rubyXL/convenience_methods.rb', line 605

def change_vertical_alignment(alignment = 'center')
  validate_worksheet
  self.style_index = workbook.modify_alignment(self.style_index) { |a| a.vertical = alignment }
end

#fill_colorObject



655
656
657
658
# File 'lib/rubyXL/convenience_methods.rb', line 655

def fill_color()
  validate_worksheet
  return workbook.get_fill_color(get_cell_xf)
end

#font_colorObject



650
651
652
653
# File 'lib/rubyXL/convenience_methods.rb', line 650

def font_color()
  validate_worksheet
  get_cell_font.get_rgb_color || '000000'
end

#font_nameObject



640
641
642
643
# File 'lib/rubyXL/convenience_methods.rb', line 640

def font_name()
  validate_worksheet
  get_cell_font.get_name
end

#font_sizeObject



645
646
647
648
# File 'lib/rubyXL/convenience_methods.rb', line 645

def font_size()
  validate_worksheet
  get_cell_font.get_size
end

#get_border(direction) ⇒ Object



595
596
597
598
# File 'lib/rubyXL/convenience_methods.rb', line 595

def get_border(direction)
  validate_worksheet
  get_cell_border.get_edge_style(direction)
end

#horizontal_alignmentObject



660
661
662
663
664
665
# File 'lib/rubyXL/convenience_methods.rb', line 660

def horizontal_alignment()
  validate_worksheet
  xf_obj = get_cell_xf
  return nil if xf_obj.alignment.nil?
  xf_obj.alignment.horizontal
end

#is_boldedObject



625
626
627
628
# File 'lib/rubyXL/convenience_methods.rb', line 625

def is_bolded()
  validate_worksheet
  get_cell_font.is_bold
end

#is_italicizedObject



620
621
622
623
# File 'lib/rubyXL/convenience_methods.rb', line 620

def is_italicized()
  validate_worksheet
  get_cell_font.is_italic
end

#is_struckthroughObject



635
636
637
638
# File 'lib/rubyXL/convenience_methods.rb', line 635

def is_struckthrough()
  validate_worksheet
  get_cell_font.is_strikethrough
end

#is_underlinedObject



630
631
632
633
# File 'lib/rubyXL/convenience_methods.rb', line 630

def is_underlined()
  validate_worksheet
  get_cell_font.is_underlined
end

#text_wrapObject



674
675
676
677
678
679
# File 'lib/rubyXL/convenience_methods.rb', line 674

def text_wrap()
  validate_worksheet
  xf_obj = get_cell_xf
  return nil if xf_obj.alignment.nil?
  xf_obj.alignment.wrap_text
end

#vertical_alignmentObject



667
668
669
670
671
672
# File 'lib/rubyXL/convenience_methods.rb', line 667

def vertical_alignment()
  validate_worksheet
  xf_obj = get_cell_xf
  return nil if xf_obj.alignment.nil?
  xf_obj.alignment.vertical
end