Module: RubyXL::LegacyCell

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#formulaObject

Returns the value of attribute formula.



15
16
17
# File 'lib/rubyXL/cell.rb', line 15

def formula
  @formula
end

#worksheetObject

Returns the value of attribute worksheet.



15
16
17
# File 'lib/rubyXL/cell.rb', line 15

def worksheet
  @worksheet
end

Instance Method Details

#border_bottomObject

returns cell’s bottom border



243
244
245
# File 'lib/rubyXL/cell.rb', line 243

def border_bottom()
  return get_border(:bottom)
end

#border_diagonalObject

returns cell’s diagonal border



248
249
250
# File 'lib/rubyXL/cell.rb', line 248

def border_diagonal()
  return get_border(:diagonal)
end

#border_leftObject

returns cell’s left border



233
234
235
# File 'lib/rubyXL/cell.rb', line 233

def border_left()
  return get_border(:left)
end

#border_rightObject

returns cell’s right border



238
239
240
# File 'lib/rubyXL/cell.rb', line 238

def border_right()
  return get_border(:right)
end

#border_topObject

returns cell’s top border



228
229
230
# File 'lib/rubyXL/cell.rb', line 228

def border_top()
  return get_border(:top)
end

#change_border_bottom(weight = 'thin') ⇒ Object

changes bottom border of cell



133
134
135
# File 'lib/rubyXL/cell.rb', line 133

def change_border_bottom(weight = 'thin')
  change_border(:bottom, weight)
end

#change_border_diagonal(weight = 'thin') ⇒ Object

changes diagonal border of cell



138
139
140
# File 'lib/rubyXL/cell.rb', line 138

def change_border_diagonal(weight = 'thin')
  change_border(:diagonal, weight)
end

#change_border_left(weight = 'thin') ⇒ Object

changes left border of cell



123
124
125
# File 'lib/rubyXL/cell.rb', line 123

def change_border_left(weight = 'thin')
  change_border(:left, weight)
end

#change_border_right(weight = 'thin') ⇒ Object

changes right border of cell



128
129
130
# File 'lib/rubyXL/cell.rb', line 128

def change_border_right(weight = 'thin')
  change_border(:right, weight)
end

#change_border_top(weight = 'thin') ⇒ Object

changes top border of cell



118
119
120
# File 'lib/rubyXL/cell.rb', line 118

def change_border_top(weight = 'thin')
  change_border(:top, weight)
end

#change_contents(data, formula_expression = nil) ⇒ Object



142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/rubyXL/cell.rb', line 142

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, Integer, Float 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_fill(rgb = 'ffffff') ⇒ Object

changes fill color of cell



22
23
24
25
26
# File 'lib/rubyXL/cell.rb', line 22

def change_fill(rgb='ffffff')
  validate_worksheet
  Color.validate_color(rgb)
  self.style_index = workbook.modify_fill(self.style_index,rgb)
end

#change_font_bold(bolded = false) ⇒ Object

Changes font bold settings of cell



67
68
69
70
71
72
73
# File 'lib/rubyXL/cell.rb', line 67

def change_font_bold(bolded = false)
  validate_worksheet

  font = get_cell_font.dup
  font.set_bold(bolded)
  update_font_references(font)
end

#change_font_color(font_color = '000000') ⇒ Object

Changes font color of cell



48
49
50
51
52
53
54
55
# File 'lib/rubyXL/cell.rb', line 48

def change_font_color(font_color = '000000')
  validate_worksheet
  Color.validate_color(font_color)

  font = get_cell_font.dup
  font.set_rgb_color(font_color)
  update_font_references(font)
end

#change_font_italics(italicized = false) ⇒ Object

Changes font italics settings of cell



58
59
60
61
62
63
64
# File 'lib/rubyXL/cell.rb', line 58

def change_font_italics(italicized = false)
  validate_worksheet

  font = get_cell_font.dup
  font.set_italic(italicized)
  update_font_references(font)
end

#change_font_name(new_font_name = 'Verdana') ⇒ Object

Changes font name of cell



29
30
31
32
33
34
35
# File 'lib/rubyXL/cell.rb', line 29

def change_font_name(new_font_name = 'Verdana')
  validate_worksheet

  font = get_cell_font.dup
  font.set_name(new_font_name)
  update_font_references(font)
end

#change_font_size(font_size = 10) ⇒ Object

Changes font size of cell



38
39
40
41
42
43
44
45
# File 'lib/rubyXL/cell.rb', line 38

def change_font_size(font_size = 10)
  validate_worksheet
  raise 'Argument must be a number' unless font_size.is_a?(Integer) || font_size.is_a?(Float)

  font = get_cell_font.dup
  font.set_size(font_size)
  update_font_references(font)
end

#change_font_strikethrough(struckthrough = false) ⇒ Object



84
85
86
87
88
89
90
# File 'lib/rubyXL/cell.rb', line 84

def change_font_strikethrough(struckthrough = false)
  validate_worksheet

  font = get_cell_font.dup
  font.set_strikethrough(struckthrough)
  update_font_references(font)
end

#change_font_underline(underlined = false) ⇒ Object

Changes font underline settings of cell



76
77
78
79
80
81
82
# File 'lib/rubyXL/cell.rb', line 76

def change_font_underline(underlined = false)
  validate_worksheet

  font = get_cell_font.dup
  font.set_underline(underlined)
  update_font_references(font)
end

#change_horizontal_alignment(alignment = 'center') ⇒ Object

changes horizontal alignment of cell



100
101
102
103
# File 'lib/rubyXL/cell.rb', line 100

def change_horizontal_alignment(alignment = 'center')
  validate_worksheet
  self.style_index = workbook.modify_alignment(self.style_index, true, alignment)
end

#change_text_wrap(wrap = false) ⇒ Object

changes wrap of cell



112
113
114
115
# File 'lib/rubyXL/cell.rb', line 112

def change_text_wrap(wrap = false)
  validate_worksheet
  self.style_index = workbook.modify_text_wrap(self.style_index, wrap)
end

#change_vertical_alignment(alignment = 'center') ⇒ Object

changes vertical alignment of cell



106
107
108
109
# File 'lib/rubyXL/cell.rb', line 106

def change_vertical_alignment(alignment = 'center')
  validate_worksheet
  self.style_index = workbook.modify_alignment(self.style_index, false, alignment)
end

#fill_colorObject

returns cell’s fill color



198
199
200
201
# File 'lib/rubyXL/cell.rb', line 198

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

#font_colorObject



192
193
194
195
# File 'lib/rubyXL/cell.rb', line 192

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

#font_nameObject



182
183
184
185
# File 'lib/rubyXL/cell.rb', line 182

def font_name()
  validate_worksheet
  get_cell_font.get_name
end

#font_sizeObject



187
188
189
190
# File 'lib/rubyXL/cell.rb', line 187

def font_size()
  validate_worksheet
  get_cell_font.get_size
end

#horizontal_alignmentObject

returns cell’s horizontal alignment



204
205
206
207
208
209
# File 'lib/rubyXL/cell.rb', line 204

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

#inspectObject



252
253
254
255
256
257
# File 'lib/rubyXL/cell.rb', line 252

def inspect
  str = "#<#{self.class}(#{row},#{column}): #{raw_value.inspect}" 
  str += " =#{self.formula.expression}" if self.formula
  str += ", datatype = #{self.datatype}, style_index = #{self.style_index}>"
  return str
end

#is_boldedObject

returns if font is bolded



167
168
169
170
# File 'lib/rubyXL/cell.rb', line 167

def is_bolded()
  validate_worksheet
  get_cell_font.is_bold
end

#is_italicizedObject

returns if font is italicized



161
162
163
164
# File 'lib/rubyXL/cell.rb', line 161

def is_italicized()
  validate_worksheet
  get_cell_font.is_italic
end

#is_struckthroughObject



177
178
179
180
# File 'lib/rubyXL/cell.rb', line 177

def is_struckthrough()
  validate_worksheet
  get_cell_font.is_strikethrough
end

#is_underlinedObject



172
173
174
175
# File 'lib/rubyXL/cell.rb', line 172

def is_underlined()
  validate_worksheet
  get_cell_font.is_underlined
end

#text_wrapObject

returns cell’s wrap



220
221
222
223
224
225
# File 'lib/rubyXL/cell.rb', line 220

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

returns cell’s vertical alignment



212
213
214
215
216
217
# File 'lib/rubyXL/cell.rb', line 212

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

#workbookObject



17
18
19
# File 'lib/rubyXL/cell.rb', line 17

def workbook
  @worksheet.workbook
end