Module: RubyXL::LegacyCell

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

Constant Summary collapse

SHARED_STRING =
's'
RAW_STRING =
'str'
ERROR =
'e'

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#formulaObject

Returns the value of attribute formula.



7
8
9
# File 'lib/rubyXL/cell.rb', line 7

def formula
  @formula
end

#worksheetObject

Returns the value of attribute worksheet.



7
8
9
# File 'lib/rubyXL/cell.rb', line 7

def worksheet
  @worksheet
end

Instance Method Details

#border_bottomObject

returns cell’s bottom border



231
232
233
# File 'lib/rubyXL/cell.rb', line 231

def border_bottom()
  return get_border(:bottom)
end

#border_diagonalObject

returns cell’s diagonal border



236
237
238
# File 'lib/rubyXL/cell.rb', line 236

def border_diagonal()
  return get_border(:diagonal)
end

#border_leftObject

returns cell’s left border



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

def border_left()
  return get_border(:left)
end

#border_rightObject

returns cell’s right border



226
227
228
# File 'lib/rubyXL/cell.rb', line 226

def border_right()
  return get_border(:right)
end

#border_topObject

returns cell’s top border



216
217
218
# File 'lib/rubyXL/cell.rb', line 216

def border_top()
  return get_border(:top)
end

#change_border_bottom(weight = 'thin') ⇒ Object

changes bottom border of cell



125
126
127
# File 'lib/rubyXL/cell.rb', line 125

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

#change_border_diagonal(weight = 'thin') ⇒ Object

changes diagonal border of cell



130
131
132
# File 'lib/rubyXL/cell.rb', line 130

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

#change_border_left(weight = 'thin') ⇒ Object

changes left border of cell



115
116
117
# File 'lib/rubyXL/cell.rb', line 115

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

#change_border_right(weight = 'thin') ⇒ Object

changes right border of cell



120
121
122
# File 'lib/rubyXL/cell.rb', line 120

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

#change_border_top(weight = 'thin') ⇒ Object

changes top border of cell



110
111
112
# File 'lib/rubyXL/cell.rb', line 110

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

#change_contents(data, formula = nil) ⇒ Object

changes contents of cell, with formula option



135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/rubyXL/cell.rb', line 135

def change_contents(data, formula=nil)
  validate_worksheet
  self.datatype = RAW_STRING

  case data
  when Date           then data = workbook.date_to_num(data)
  when Integer, Float then self.datatype = ''
  end

  self.raw_value = data
  @formula = formula
end

#change_fill(rgb = 'ffffff') ⇒ Object

changes fill color of cell



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



92
93
94
95
# File 'lib/rubyXL/cell.rb', line 92

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



104
105
106
107
# File 'lib/rubyXL/cell.rb', line 104

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



98
99
100
101
# File 'lib/rubyXL/cell.rb', line 98

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



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

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

#font_colorObject



180
181
182
183
# File 'lib/rubyXL/cell.rb', line 180

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

#font_nameObject



170
171
172
173
# File 'lib/rubyXL/cell.rb', line 170

def font_name()
  validate_worksheet
  get_cell_font.get_name
end

#font_sizeObject



175
176
177
178
# File 'lib/rubyXL/cell.rb', line 175

def font_size()
  validate_worksheet
  get_cell_font.get_size
end

#horizontal_alignmentObject

returns cell’s horizontal alignment



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

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

#inspectObject



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

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

#is_boldedObject

returns if font is bolded



155
156
157
158
# File 'lib/rubyXL/cell.rb', line 155

def is_bolded()
  validate_worksheet
  get_cell_font.is_bold
end

#is_italicizedObject

returns if font is italicized



149
150
151
152
# File 'lib/rubyXL/cell.rb', line 149

def is_italicized()
  validate_worksheet
  get_cell_font.is_italic
end

#is_struckthroughObject



165
166
167
168
# File 'lib/rubyXL/cell.rb', line 165

def is_struckthrough()
  validate_worksheet
  get_cell_font.is_strikethrough
end

#is_underlinedObject



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

def is_underlined()
  validate_worksheet
  get_cell_font.is_underlined
end

#text_wrapObject

returns cell’s wrap



208
209
210
211
212
213
# File 'lib/rubyXL/cell.rb', line 208

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



200
201
202
203
204
205
# File 'lib/rubyXL/cell.rb', line 200

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

#workbookObject



9
10
11
# File 'lib/rubyXL/cell.rb', line 9

def workbook
  @worksheet.workbook
end