def write_root_rels(workbook):
 root = Element('Relationships', xmlns=PKG_REL_NS)
 relation_tag = ('{%s}Relationship' % PKG_REL_NS)
 rel = Relationship(type='officeDocument', target=ARC_WORKBOOK, id='rId1')
 root.append(rel.to_tree())
 rel = Relationship('', target=ARC_CORE, id='rId2')
 rel.type = ('%s/metadata/core-properties' % PKG_REL_NS)
 root.append(rel.to_tree())
 rel = Relationship('extended-properties', target=ARC_APP, id='rId3')
 root.append(rel.to_tree())
 if (workbook.vba_archive is not None):
  arc = fromstring(workbook.vba_archive.read(ARC_ROOT_RELS))
  rels = arc.findall(relation_tag)
  rId = None
  for rel in rels:
   if (rel.get('Target') == ARC_CUSTOM_UI):
    rId = rel.get('Id')
    break
  if (rId is not None):
   vba = Relationship('', target=ARC_CUSTOM_UI, id=rId)
   vba.type = CUSTOMUI_NS
   root.append(vba.to_tree())
 return tostring(root)

def write_root_rels ( workbook ) : root = Element ( 'Relationships' , xmlns = PKG_REL_NS ) relation_tag = ( '{%s}Relationship' % PKG_REL_NS ) rel = Relationship ( type = 'officeDocument' , target = ARC_WORKBOOK , id = 'rId1' ) root . append ( rel . to_tree ( ) ) rel = Relationship ( '' , target = ARC_CORE , id = 'rId2' ) rel . type = ( '%s/metadata/core-properties' % PKG_REL_NS ) root . append ( rel . to_tree ( ) ) rel = Relationship ( 'extended-properties' , target = ARC_APP , id = 'rId3' ) root . append ( rel . to_tree ( ) ) if ( workbook . vba_archive is not None ) : arc = fromstring ( workbook . vba_archive . read ( ARC_ROOT_RELS ) ) rels = arc . findall ( relation_tag ) rId = None for rel in rels : if ( rel . get ( 'Target' ) == ARC_CUSTOM_UI ) : rId = rel . get ( 'Id' ) break if ( rId is not None ) : vba = Relationship ( '' , target = ARC_CUSTOM_UI , id = rId ) vba . type = CUSTOMUI_NS root . append ( vba . to_tree ( ) ) return tostring ( root )
write the relationships xml .