Class: Writexlsx::Package::Relationships

Inherits:
Object
  • Object
show all
Includes:
Utility
Defined in:
lib/write_xlsx/package/relationships.rb

Constant Summary collapse

Schema_root =
'http://schemas.openxmlformats.org'
Package_schema =
Schema_root + '/package/2006/relationships'
Document_schema =
Schema_root + '/officeDocument/2006/relationships'

Constants included from Utility

Utility::COL_MAX, Utility::ROW_MAX, Utility::SHEETNAME_MAX, Utility::STR_MAX

Instance Method Summary collapse

Methods included from Utility

#absolute_char, delete_files, #put_deprecate_message, #substitute_cellref, #underline_attributes, #xl_cell_to_rowcol, #xl_col_to_name, #xl_range, #xl_range_formula, #xl_rowcol_to_cell, #xml_str

Constructor Details

#initializeRelationships

Returns a new instance of Relationships.



15
16
17
18
19
# File 'lib/write_xlsx/package/relationships.rb', line 15

def initialize
  @writer = Package::XMLWriterSimple.new
  @rels   = []
  @id     = 1
end

Instance Method Details

#add_document_relationship(type, target) ⇒ Object

Add container relationship to XLSX .rels xml files.



35
36
37
38
39
40
# File 'lib/write_xlsx/package/relationships.rb', line 35

def add_document_relationship(type, target)
  type   = Document_schema + type
  target = target

  @rels.push([type, target])
end

#add_package_relationship(type, target) ⇒ Object

Add container relationship to XLSX .rels xml files.



45
46
47
48
49
50
# File 'lib/write_xlsx/package/relationships.rb', line 45

def add_package_relationship(type, target)
  type   = Package_schema + type
  target = target + '.xml'

  @rels.push([type, target])
end

#add_worksheet_relationship(type, target, target_mode) ⇒ Object

Add worksheet relationship to sheet.rels xml files.



55
56
57
58
59
60
# File 'lib/write_xlsx/package/relationships.rb', line 55

def add_worksheet_relationship(type, target, target_mode)
  type   = Document_schema + type
  target = target

  @rels.push([type, target, target_mode])
end

#assemble_xml_fileObject



25
26
27
28
29
30
# File 'lib/write_xlsx/package/relationships.rb', line 25

def assemble_xml_file
  write_xml_declaration
  write_relationships
  @writer.crlf
  @writer.close
end

#set_xml_writer(filename) ⇒ Object



21
22
23
# File 'lib/write_xlsx/package/relationships.rb', line 21

def set_xml_writer(filename)
  @writer.set_xml_writer(filename)
end