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



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

def border_bottom()
  return get_border(:bottom)
end

#border_diagonalObject

returns cell’s diagonal border



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

def border_diagonal()
  return get_border(:diagonal)
end

#border_leftObject

returns cell’s left border



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

def border_left()
  return get_border(:left)
end

#border_rightObject

returns cell’s right border



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

def border_right()
  return get_border(:right)
end

#border_topObject

returns cell’s top border



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

def border_top()
  return get_border(:top)
end

#change_border_bottom(weight = 'thin') ⇒ Object

changes bottom border of cell



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

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

#change_border_diagonal(weight = 'thin') ⇒ Object

changes diagonal border of cell



136
137
138
# File 'lib/rubyXL/cell.rb', line 136

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

#change_border_left(weight = 'thin') ⇒ Object

changes left border of cell



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

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

#change_border_right(weight = 'thin') ⇒ Object

changes right border of cell



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

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

#change_border_top(weight = 'thin') ⇒ Object

changes top border of cell



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

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

#change_contents(data, formula = nil) ⇒ Object

changes contents of cell, with formula option



141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/rubyXL/cell.rb', line 141

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



20
21
22
23
24
# File 'lib/rubyXL/cell.rb', line 20

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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

#font_colorObject



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

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

#font_nameObject



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

def font_name()
  validate_worksheet
  get_cell_font.get_name
end

#font_sizeObject



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

def font_size()
  validate_worksheet
  get_cell_font.get_size
end

#horizontal_alignmentObject

returns cell’s horizontal alignment



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

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

#inspectObject



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

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



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

def is_bolded()
  validate_worksheet
  get_cell_font.is_bold
end

#is_date?Boolean

Returns:

  • (Boolean)


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

def is_date?
  return false unless raw_value =~ /^\d+$/ # Only fully numeric values can be dates
  num_fmt = get_number_format
  num_fmt && num_fmt.is_date_format?
end

#is_italicizedObject

returns if font is italicized



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

def is_italicized()
  validate_worksheet
  get_cell_font.is_italic
end

#is_struckthroughObject



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

def is_struckthrough()
  validate_worksheet
  get_cell_font.is_strikethrough
end

#is_underlinedObject



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

def is_underlined()
  validate_worksheet
  get_cell_font.is_underlined
end

#text_wrapObject

returns cell’s wrap



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

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



206
207
208
209
210
211
# File 'lib/rubyXL/cell.rb', line 206

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