lib/rubyXL/objects/worksheet.rb in rubyXL-2.5.7 vs lib/rubyXL/objects/worksheet.rb in rubyXL-3.0.0

- old
+ new

@@ -304,11 +304,11 @@ define_element_name 'hyperlink' end # http://www.schemacentral.com/sc/ooxml/e-ssml_hyperlinks-1.html class Hyperlinks < OOXMLContainerObject - define_child_node(RubyXL::Hyperlink, :colection => true) + define_child_node(RubyXL::Hyperlink, :collection => true) define_element_name 'hyperlinks' end # http://www.schemacentral.com/sc/ooxml/e-ssml_oleObject-1.html class OLEObject < OOXMLObject @@ -322,11 +322,11 @@ define_element_name 'oleObject' end # http://www.schemacentral.com/sc/ooxml/e-ssml_oleObjects-1.html class OLEObjects < OOXMLContainerObject - define_child_node(RubyXL::OLEObject, :colection => true) + define_child_node(RubyXL::OLEObject, :collection => true) define_element_name 'oleObjects' end # http://www.schemacentral.com/sc/ooxml/e-ssml_dataRef-1.html class DataConsolidationReference < OOXMLObject @@ -650,12 +650,15 @@ 'http://schemas.openxmlformats.org/officeDocument/2006/relationships' => 'r', 'http://schemas.openxmlformats.org/markup-compatibility/2006' => 'mc', 'http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac' => 'x14ac', 'urn:schemas-microsoft-com:mac:vml' => 'mv') - attr_accessor :workbook, :state, :sheet_name, :sheet_id + attr_accessor :workbook, :state, :sheet_name, :sheet_id, :rels, :comments, :printer_settings + CONTENT_TYPE = 'application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml' + REL_TYPE = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet' + def before_write_xml # This method may need to be moved higher in the hierarchy first_nonempty_row = nil last_nonempty_row = 0 first_nonempty_column = nil last_nonempty_column = 0 @@ -697,26 +700,47 @@ end true end - def sheet_index - @workbook.worksheets.select{ |sheet| sheet.is_a?(self.class) }.index{ |sheet| sheet.equal?(self) } + include RubyXL::RelationshipSupport + + def related_objects + comments + printer_settings end - def xlsx_path - File.join('xl', 'worksheets', "sheet#{sheet_index + 1}.xml") + def relationship_file_class + RubyXL::SheetRelationshipsFile end - def self.content_type - 'application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml' + def attach_relationship(rid, rf) + case rf + when RubyXL::PrinterSettingsFile then printer_settings << rf + when RubyXL::CommentsFile then comments << rf + when RubyXL::VMLDrawingFile then store_relationship(rf) # TODO + when RubyXL::DrawingFile then store_relationship(rf) # TODO + when RubyXL::BinaryImageFile then store_relationship(rf) # TODO + when RubyXL::PivotTableFile then store_relationship(rf) # TODO + when RubyXL::TableFile then store_relationship(rf) # TODO + when RubyXL::ControlPropertiesFile then store_relationship(rf) # TODO + when RubyXL::SlicerFile then store_relationship(rf) # TODO + else store_relationship(rf, :unknown) + end end - def rel_type - 'worksheet' + def xlsx_path + File.join('xl', 'worksheets', "sheet#{file_index}.xml") end + def self.parse(param) + sheet_obj = super + sheet_obj.sheet_data.rows.each { |r| + next if r.nil? + r.worksheet = sheet_obj + r.cells.each { |c| c.worksheet = sheet_obj unless c.nil? } + } + sheet_obj + end include LegacyWorksheet - end end