Module: RubyXL::LegacyCell
- Included in:
- Cell
- Defined in:
- lib/rubyXL/cell.rb
Instance Attribute Summary collapse
-
#formula ⇒ Object
Returns the value of attribute formula.
-
#worksheet ⇒ Object
Returns the value of attribute worksheet.
Instance Method Summary collapse
-
#border_bottom ⇒ Object
returns cell’s bottom border.
-
#border_diagonal ⇒ Object
returns cell’s diagonal border.
-
#border_left ⇒ Object
returns cell’s left border.
-
#border_right ⇒ Object
returns cell’s right border.
-
#border_top ⇒ Object
returns cell’s top border.
- #change_border(direction, weight) ⇒ Object
- #change_border_bottom(weight = 'thin') ⇒ Object
- #change_border_diagonal(weight = 'thin') ⇒ Object
- #change_border_left(weight = 'thin') ⇒ Object
- #change_border_right(weight = 'thin') ⇒ Object
- #change_border_top(weight = 'thin') ⇒ Object
- #change_contents(data, formula_expression = nil) ⇒ Object
-
#change_fill(rgb = 'ffffff') ⇒ Object
changes fill color of cell.
-
#change_font_bold(bolded = false) ⇒ Object
Changes font bold settings of cell.
-
#change_font_color(font_color = '000000') ⇒ Object
Changes font color of cell.
-
#change_font_italics(italicized = false) ⇒ Object
Changes font italics settings of cell.
-
#change_font_name(new_font_name = 'Verdana') ⇒ Object
Changes font name of cell.
-
#change_font_size(font_size = 10) ⇒ Object
Changes font size of cell.
- #change_font_strikethrough(struckthrough = false) ⇒ Object
-
#change_font_underline(underlined = false) ⇒ Object
Changes font underline settings of cell.
-
#change_horizontal_alignment(alignment = 'center') ⇒ Object
changes horizontal alignment of cell.
-
#change_text_wrap(wrap = false) ⇒ Object
changes wrap of cell.
-
#change_vertical_alignment(alignment = 'center') ⇒ Object
changes vertical alignment of cell.
-
#fill_color ⇒ Object
returns cell’s fill color.
- #font_color ⇒ Object
- #font_name ⇒ Object
- #font_size ⇒ Object
-
#font_switch(change_type, arg) ⇒ Object
Performs correct modification based on what type of change_type is specified.
-
#horizontal_alignment ⇒ Object
returns cell’s horizontal alignment.
- #inspect ⇒ Object
-
#is_bolded ⇒ Object
returns if font is bolded.
-
#is_italicized ⇒ Object
returns if font is italicized.
- #is_struckthrough ⇒ Object
- #is_underlined ⇒ Object
-
#text_wrap ⇒ Object
returns cell’s wrap.
-
#vertical_alignment ⇒ Object
returns cell’s vertical alignment.
- #workbook ⇒ Object
Instance Attribute Details
#formula ⇒ Object
Returns the value of attribute formula.
15 16 17 |
# File 'lib/rubyXL/cell.rb', line 15 def formula @formula end |
#worksheet ⇒ Object
Returns the value of attribute worksheet.
15 16 17 |
# File 'lib/rubyXL/cell.rb', line 15 def worksheet @worksheet end |
Instance Method Details
#border_bottom ⇒ Object
returns cell’s bottom border
248 249 250 |
# File 'lib/rubyXL/cell.rb', line 248 def border_bottom() return get_border(:bottom) end |
#border_diagonal ⇒ Object
returns cell’s diagonal border
253 254 255 |
# File 'lib/rubyXL/cell.rb', line 253 def border_diagonal() return get_border(:diagonal) end |
#border_left ⇒ Object
returns cell’s left border
238 239 240 |
# File 'lib/rubyXL/cell.rb', line 238 def border_left() return get_border(:left) end |
#border_right ⇒ Object
returns cell’s right border
243 244 245 |
# File 'lib/rubyXL/cell.rb', line 243 def border_right() return get_border(:right) end |
#border_top ⇒ Object
returns cell’s top border
233 234 235 |
# File 'lib/rubyXL/cell.rb', line 233 def border_top() return get_border(:top) end |
#change_border(direction, weight) ⇒ Object
117 118 119 120 |
# File 'lib/rubyXL/cell.rb', line 117 def change_border(direction, weight) validate_worksheet self.style_index = workbook.modify_border(self.style_index, direction, weight) end |
#change_border_bottom(weight = 'thin') ⇒ Object
137 138 139 140 |
# File 'lib/rubyXL/cell.rb', line 137 def change_border_bottom(weight = 'thin') warn "[DEPRECATION] `#{__method__}` is deprecated. Please use `change_border` instead." change_border(:bottom, weight) end |
#change_border_diagonal(weight = 'thin') ⇒ Object
142 143 144 145 |
# File 'lib/rubyXL/cell.rb', line 142 def change_border_diagonal(weight = 'thin') warn "[DEPRECATION] `#{__method__}` is deprecated. Please use `change_border` instead." change_border(:diagonal, weight) end |
#change_border_left(weight = 'thin') ⇒ Object
127 128 129 130 |
# File 'lib/rubyXL/cell.rb', line 127 def change_border_left(weight = 'thin') warn "[DEPRECATION] `#{__method__}` is deprecated. Please use `change_border` instead." change_border(:left, weight) end |
#change_border_right(weight = 'thin') ⇒ Object
132 133 134 135 |
# File 'lib/rubyXL/cell.rb', line 132 def change_border_right(weight = 'thin') warn "[DEPRECATION] `#{__method__}` is deprecated. Please use `change_border` instead." change_border(:right, weight) end |
#change_border_top(weight = 'thin') ⇒ Object
122 123 124 125 |
# File 'lib/rubyXL/cell.rb', line 122 def change_border_top(weight = 'thin') warn "[DEPRECATION] `#{__method__}` is deprecated. Please use `change_border` instead." change_border(:top, weight) end |
#change_contents(data, formula_expression = nil) ⇒ Object
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/rubyXL/cell.rb', line 147 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_color ⇒ Object
returns cell’s fill color
203 204 205 206 |
# File 'lib/rubyXL/cell.rb', line 203 def fill_color() validate_worksheet return workbook.get_fill_color(get_cell_xf) end |
#font_color ⇒ Object
197 198 199 200 |
# File 'lib/rubyXL/cell.rb', line 197 def font_color() validate_worksheet get_cell_font.get_rgb_color || '000000' end |
#font_name ⇒ Object
187 188 189 190 |
# File 'lib/rubyXL/cell.rb', line 187 def font_name() validate_worksheet get_cell_font.get_name end |
#font_size ⇒ Object
192 193 194 195 |
# File 'lib/rubyXL/cell.rb', line 192 def font_size() validate_worksheet get_cell_font.get_size end |
#font_switch(change_type, arg) ⇒ Object
Performs correct modification based on what type of change_type is specified
265 266 267 268 269 270 271 272 273 274 275 276 |
# File 'lib/rubyXL/cell.rb', line 265 def font_switch(change_type, arg) case change_type when Worksheet::NAME then change_font_name(arg) when Worksheet::SIZE then change_font_size(arg) when Worksheet::COLOR then change_font_color(arg) when Worksheet::ITALICS then change_font_italics(arg) when Worksheet::BOLD then change_font_bold(arg) when Worksheet::UNDERLINE then change_font_underline(arg) when Worksheet::STRIKETHROUGH then change_font_strikethrough(arg) else raise 'Invalid change_type' end end |
#horizontal_alignment ⇒ Object
returns cell’s horizontal alignment
209 210 211 212 213 214 |
# File 'lib/rubyXL/cell.rb', line 209 def horizontal_alignment() validate_worksheet xf_obj = get_cell_xf return nil if xf_obj.alignment.nil? xf_obj.alignment.horizontal end |
#inspect ⇒ Object
257 258 259 260 261 262 |
# File 'lib/rubyXL/cell.rb', line 257 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_bolded ⇒ Object
returns if font is bolded
172 173 174 175 |
# File 'lib/rubyXL/cell.rb', line 172 def is_bolded() validate_worksheet get_cell_font.is_bold end |
#is_italicized ⇒ Object
returns if font is italicized
166 167 168 169 |
# File 'lib/rubyXL/cell.rb', line 166 def is_italicized() validate_worksheet get_cell_font.is_italic end |
#is_struckthrough ⇒ Object
182 183 184 185 |
# File 'lib/rubyXL/cell.rb', line 182 def is_struckthrough() validate_worksheet get_cell_font.is_strikethrough end |
#is_underlined ⇒ Object
177 178 179 180 |
# File 'lib/rubyXL/cell.rb', line 177 def is_underlined() validate_worksheet get_cell_font.is_underlined end |
#text_wrap ⇒ Object
returns cell’s wrap
225 226 227 228 229 230 |
# File 'lib/rubyXL/cell.rb', line 225 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 ⇒ Object
returns cell’s vertical alignment
217 218 219 220 221 222 |
# File 'lib/rubyXL/cell.rb', line 217 def vertical_alignment() validate_worksheet xf_obj = get_cell_xf return nil if xf_obj.alignment.nil? xf_obj.alignment.vertical end |
#workbook ⇒ Object
17 18 19 |
# File 'lib/rubyXL/cell.rb', line 17 def workbook @worksheet.workbook end |