def write_workbook_rels(workbook):
 root = Element('Relationships', {'xmlns': 'http://schemas.openxmlformats.org/package/2006/relationships'})
 for i in range(len(workbook.worksheets)):
  SubElement(root, 'Relationship', {'Id': ('rId%d' % (i + 1)), 'Type': 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet', 'Target': ('worksheets/sheet%s.xml' % (i + 1))})
 rid = (len(workbook.worksheets) + 1)
 SubElement(root, 'Relationship', {'Id': ('rId%d' % rid), 'Target': 'sharedStrings.xml', 'Type': 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings'})
 SubElement(root, 'Relationship', {'Id': ('rId%d' % (rid + 1)), 'Target': 'styles.xml', 'Type': 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles'})
 SubElement(root, 'Relationship', {'Id': ('rId%d' % (rid + 2)), 'Target': 'theme/theme1.xml', 'Type': 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme'})
 return get_document_content(root)

def write_workbook_rels ( workbook ) : root = Element ( 'Relationships' , { 'xmlns' : 'http://schemas.openxmlformats.org/package/2006/relationships' } ) for i in range ( len ( workbook . worksheets ) ) : SubElement ( root , 'Relationship' , { 'Id' : ( 'rId%d' % ( i + 1 ) ) , 'Type' : 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet' , 'Target' : ( 'worksheets/sheet%s.xml' % ( i + 1 ) ) } ) rid = ( len ( workbook . worksheets ) + 1 ) SubElement ( root , 'Relationship' , { 'Id' : ( 'rId%d' % rid ) , 'Target' : 'sharedStrings.xml' , 'Type' : 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings' } ) SubElement ( root , 'Relationship' , { 'Id' : ( 'rId%d' % ( rid + 1 ) ) , 'Target' : 'styles.xml' , 'Type' : 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles' } ) SubElement ( root , 'Relationship' , { 'Id' : ( 'rId%d' % ( rid + 2 ) ) , 'Target' : 'theme/theme1.xml' , 'Type' : 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme' } ) return get_document_content ( root )
write the workbook relationships xml .