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, #check_dimensions, #check_dimensions_and_update_max_min_values, #check_parameter, #convert_date_time, #dash_types, delete_files, #fill_properties, #float_to_str, #layout_properties, #line_fill_properties, #line_properties, #palette_color, #pixels_to_points, #process_workbook_options, #ptrue?, #put_deprecate_message, #quote_sheetname, #r_id_attributes, #row_col_notation, #shape_style_base, #store_col_max_min_values, #store_row_max_min_values, #substitute_cellref, #underline_attributes, #v_shape_attributes_base, #v_shape_style_base, #value_or_raise, #write_anchor, #write_auto_fill, #write_color, #write_comment_path, #write_div, #write_fill, #write_font, #write_stroke, #write_xml_declaration, #xl_cell_to_rowcol, #xl_col_to_name, #xl_range, #xl_range_formula, #xl_rowcol_to_cell, #xml_str

Constructor Details

#initializeRelationships


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.


34
35
36
# File 'lib/write_xlsx/package/relationships.rb', line 34

def add_document_relationship(type, target)
  @rels.push([Document_schema + type, target])
end

#add_ms_package_relationship(type, target) ⇒ Object

Add container relationship to XLSX .rels xml files. Uses MS schema.


48
49
50
51
# File 'lib/write_xlsx/package/relationships.rb', line 48

def add_ms_package_relationship(type, target)
  schema = 'http://schemas.microsoft.com/office/2006/relationships'
  @rels.push([schema + type, target])
end

#add_package_relationship(type, target) ⇒ Object

Add container relationship to XLSX .rels xml files.


41
42
43
# File 'lib/write_xlsx/package/relationships.rb', line 41

def add_package_relationship(type, target)
  @rels.push([Package_schema + type, target])
end

#add_worksheet_relationship(type, target, target_mode = nil) ⇒ Object

Add worksheet relationship to sheet.rels xml files.


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

def add_worksheet_relationship(type, target, target_mode = nil)
  @rels.push([Document_schema + type, target, target_mode])
end

#assemble_xml_fileObject


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

def assemble_xml_file
  write_xml_declaration do
    write_relationships
  end
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