Class: RubyXL::Stylesheet

Inherits:
OOXMLObject show all
Defined in:
lib/rubyXL/objects/stylesheet.rb

Overview

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from OOXMLObject

#add_to_zip, #before_write_xml, define_attribute, define_child_node, define_element_name, #dup, #index_in_collection, obtain_class_variable, parse, parse_file, set_countable, set_namespaces, #write_xml

Constructor Details

#initialize(*args) ⇒ Stylesheet

Returns a new instance of Stylesheet.



169
170
171
172
# File 'lib/rubyXL/objects/stylesheet.rb', line 169

def initialize(*args)
  super
  @format_hash = nil
end

Class Method Details

.defaultObject



178
179
180
181
182
183
184
185
# File 'lib/rubyXL/objects/stylesheet.rb', line 178

def self.default
  self.new(:cell_xf_container       => RubyXL::CellXFContainer.defaults,
           :font_container          => RubyXL::FontContainer.defaults,
           :fill_container          => RubyXL::FillContainer.defaults,
           :border_container        => RubyXL::BorderContainer.defaults, 
           :cell_style_container    => RubyXL::CellStyleContainer.defaults,
           :cell_style_xf_container => RubyXL::CellStyleXFContainer.defaults)
end

.filepathObject



174
175
176
# File 'lib/rubyXL/objects/stylesheet.rb', line 174

def self.filepath
  File.join('xl', 'styles.xml')
end

Instance Method Details

#get_number_format_by_id(format_id) ⇒ Object



187
188
189
190
191
192
193
194
195
196
# File 'lib/rubyXL/objects/stylesheet.rb', line 187

def get_number_format_by_id(format_id)
  @format_hash ||= {}
  
  if @format_hash[format_id].nil? then
    @format_hash[format_id] = NumberFormatContainer::DEFAULT_NUMBER_FORMATS.find_by_format_id(format_id) ||
                                (number_format_container && number_format_container.find_by_format_id(format_id))
  end

  @format_hash[format_id]
end