def write_cols(worksheet):
 def sorter(value):
  return column_index_from_string(value[0])
 el = Element('cols')
 obj = None
 for (idx, col) in sorted(worksheet.column_dimensions.items(), key=sorter):
  if (dict(col) == {}):
   continue
  idx = column_index_from_string(idx)
  obj = Element('col', dict(col))
  obj.set('min', ('%d' % (col.min or idx)))
  obj.set('max', ('%d' % (col.max or idx)))
  el.append(obj)
 if (obj is not None):
  return el

def write_cols ( worksheet ) : def sorter ( value ) : return column_index_from_string ( value [ 0 ] ) el = Element ( 'cols' ) obj = None for ( idx , col ) in sorted ( worksheet . column_dimensions . items ( ) , key = sorter ) : if ( dict ( col ) == { } ) : continue idx = column_index_from_string ( idx ) obj = Element ( 'col' , dict ( col ) ) obj . set ( 'min' , ( '%d' % ( col . min or idx ) ) ) obj . set ( 'max' , ( '%d' % ( col . max or idx ) ) ) el . append ( obj ) if ( obj is not None ) : return el
write worksheet columns to xml .