def write_string_table(string_table):
 temp_buffer = StringIO()
 doc = XMLGenerator(temp_buffer, 'utf-8')
 start_tag(doc, 'sst', {'xmlns': 'http://schemas.openxmlformats.org/spreadsheetml/2006/main', 'uniqueCount': ('%d' % len(string_table))})
 strings_to_write = sorted(iter(string_table.items()), key=(lambda pair: pair[1]))
 for key in [pair[0] for pair in strings_to_write]:
  start_tag(doc, 'si')
  if (key.strip() != key):
   attr = {'xml:space': 'preserve'}
  else:
   attr = {}
  tag(doc, 't', attr, key)
  end_tag(doc, 'si')
 end_tag(doc, 'sst')
 string_table_xml = temp_buffer.getvalue()
 temp_buffer.close()
 return string_table_xml

def write_string_table ( string_table ) : temp_buffer = StringIO ( ) doc = XMLGenerator ( temp_buffer , 'utf-8' ) start_tag ( doc , 'sst' , { 'xmlns' : 'http://schemas.openxmlformats.org/spreadsheetml/2006/main' , 'uniqueCount' : ( '%d' % len ( string_table ) ) } ) strings_to_write = sorted ( iter ( string_table . items ( ) ) , key = ( lambda pair : pair [ 1 ] ) ) for key in [ pair [ 0 ] for pair in strings_to_write ] : start_tag ( doc , 'si' ) if ( key . strip ( ) != key ) : attr = { 'xml:space' : 'preserve' } else : attr = { } tag ( doc , 't' , attr , key ) end_tag ( doc , 'si' ) end_tag ( doc , 'sst' ) string_table_xml = temp_buffer . getvalue ( ) temp_buffer . close ( ) return string_table_xml
write the string table xml .