class RubyXL::OOXMLTopLevelObject
their own .xml
files in .xslx
zip container.
Extension class providing functionality for top-level OOXML objects that are represented by
def self.parse_file(zip_file, file_path)
=== Parameters
directory containing the unzipped contents of .xslx
Generates the top-level OOXML object by parsing its XML file from the temporary
def self.parse_file(zip_file, file_path) entry = zip_file.find_entry(RubyXL::from_root(file_path)) # Accomodate for Nokogiri Java implementation which is incapable of reading from a stream entry && (entry.get_input_stream { |f| parse(defined?(JRUBY_VERSION) ? f.read : f) }) end
def self.set_namespaces(namespace_hash)
set_namespaces('http://schemas.openxmlformats.org/spreadsheetml/2006/main' => '',
==== Examples
* +namespace_hash+ - Hash of namespaces in the form of "prefix" => "url"
=== Parameters
Sets the list of namespaces on this object to be added when writing out XML. Valid only on top-level objects.
def self.set_namespaces(namespace_hash) self.class_variable_set(:@@ooxml_namespaces, namespace_hash) end
def add_to_zip(zip_stream)
=== Parameters
Saves the contents of the object as XML to respective location in .xslx zip container.
def add_to_zip(zip_stream) xml_string = write_xml return if xml_string.empty? zip_stream.put_next_entry(RubyXL::from_root(self.xlsx_path)) zip_stream.write(xml_string) end
def file_index
def file_index root.rels_hash[self.class].index{ |f| f.equal?(self) }.to_i + 1 end
def xlsx_path
Prototype method. For top-level OOXML object, returns the path at which the current object's XML file
def xlsx_path raise 'Subclass responsebility' end