Class: OOXML::Excel::Sheet::Row::Cell
- Inherits:
-
Object
- Object
- OOXML::Excel::Sheet::Row::Cell
- Defined in:
- lib/ooxml_excel/sheet.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#shared_strings ⇒ Object
Returns the value of attribute shared_strings.
-
#style_id ⇒ Object
Returns the value of attribute style_id.
-
#styles ⇒ Object
Returns the value of attribute styles.
-
#type_id ⇒ Object
Returns the value of attribute type_id.
-
#value_id ⇒ Object
Returns the value of attribute value_id.
Class Method Summary collapse
Instance Method Summary collapse
- #fill ⇒ Object
- #font ⇒ Object
-
#initialize(**attrs) ⇒ Cell
constructor
A new instance of Cell.
- #number_format ⇒ Object
- #style ⇒ Object
- #type ⇒ Object
- #value ⇒ Object
Constructor Details
#initialize(**attrs) ⇒ Cell
Returns a new instance of Cell.
190 191 192 |
# File 'lib/ooxml_excel/sheet.rb', line 190 def initialize(**attrs) attrs.each { |property, value| send("#{property}=", value)} end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
188 189 190 |
# File 'lib/ooxml_excel/sheet.rb', line 188 def id @id end |
#shared_strings ⇒ Object
Returns the value of attribute shared_strings.
188 189 190 |
# File 'lib/ooxml_excel/sheet.rb', line 188 def shared_strings @shared_strings end |
#style_id ⇒ Object
Returns the value of attribute style_id.
188 189 190 |
# File 'lib/ooxml_excel/sheet.rb', line 188 def style_id @style_id end |
#styles ⇒ Object
Returns the value of attribute styles.
188 189 190 |
# File 'lib/ooxml_excel/sheet.rb', line 188 def styles @styles end |
#type_id ⇒ Object
Returns the value of attribute type_id.
188 189 190 |
# File 'lib/ooxml_excel/sheet.rb', line 188 def type_id @type_id end |
#value_id ⇒ Object
Returns the value of attribute value_id.
188 189 190 |
# File 'lib/ooxml_excel/sheet.rb', line 188 def value_id @value_id end |
Class Method Details
.load_from_node(cell_node, shared_strings, styles) ⇒ Object
242 243 244 245 246 247 248 249 |
# File 'lib/ooxml_excel/sheet.rb', line 242 def self.load_from_node(cell_node, shared_strings, styles) new(id: cell_node.attributes["r"].try(:value), type_id: cell_node.attributes["t"].try(:value), style_id: cell_node.attributes["s"].try(:value), value_id: cell_node.at('v').try(:text), shared_strings: shared_strings, styles: styles ) end |
Instance Method Details
#fill ⇒ Object
228 229 230 |
# File 'lib/ooxml_excel/sheet.rb', line 228 def fill (style.present?) ? style[:fill]: nil end |
#font ⇒ Object
224 225 226 |
# File 'lib/ooxml_excel/sheet.rb', line 224 def font (style.present?) ? style[:font] : nil end |
#number_format ⇒ Object
217 218 219 220 221 222 |
# File 'lib/ooxml_excel/sheet.rb', line 217 def number_format if (style.present?) nf = style[:number_format] (nf.present?) ? nf.gsub("\\", "") : nil end end |
#style ⇒ Object
209 210 211 212 213 214 215 |
# File 'lib/ooxml_excel/sheet.rb', line 209 def style @style ||= begin if s.present? style = styles.by_id(s.to_i) end end end |
#type ⇒ Object
194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
# File 'lib/ooxml_excel/sheet.rb', line 194 def type @type ||= begin case type_id when 's' then :string when 'n' then :number when 'b' then :boolean when 'd' then :date when 'str' then :formula when 'inlineStr' then :inline_str else :error end end end |
#value ⇒ Object
232 233 234 235 236 237 238 239 240 |
# File 'lib/ooxml_excel/sheet.rb', line 232 def value case type when :string (value_id.present?) ? shared_strings[value_id.to_i] : nil else # TODO: to support other types soon value_id end end |