def write_worksheet_rels(worksheet, idx):
 root = Element('Relationships', {'xmlns': 'http://schemas.openxmlformats.org/package/2006/relationships'})
 for rel in worksheet.relationships:
  attrs = {'Id': rel.id, 'Type': rel.type, 'Target': rel.target}
  if rel.target_mode:
   attrs['TargetMode'] = rel.target_mode
  SubElement(root, 'Relationship', attrs)
 if worksheet._charts:
  attrs = {'Id': 'rId1', 'Type': 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing', 'Target': ('../drawings/drawing%s.xml' % idx)}
  SubElement(root, 'Relationship', attrs)
 return get_document_content(root)

def write_worksheet_rels ( worksheet , idx ) : root = Element ( 'Relationships' , { 'xmlns' : 'http://schemas.openxmlformats.org/package/2006/relationships' } ) for rel in worksheet . relationships : attrs = { 'Id' : rel . id , 'Type' : rel . type , 'Target' : rel . target } if rel . target_mode : attrs [ 'TargetMode' ] = rel . target_mode SubElement ( root , 'Relationship' , attrs ) if worksheet . _charts : attrs = { 'Id' : 'rId1' , 'Type' : 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing' , 'Target' : ( '../drawings/drawing%s.xml' % idx ) } SubElement ( root , 'Relationship' , attrs ) return get_document_content ( root )
write relationships for the worksheet to xml .