def read_style_table(xml_source):
 table = {}
 xmlns = 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'
 root = fromstring(xml_source)
 custom_num_formats = parse_custom_num_formats(root, xmlns)
 builtin_formats = NumberFormat._BUILTIN_FORMATS
 cell_xfs = root.find(QName(xmlns, 'cellXfs').text)
 cell_xfs_nodes = cell_xfs.findall(QName(xmlns, 'xf').text)
 for (index, cell_xfs_node) in enumerate(cell_xfs_nodes):
  new_style = Style()
  number_format_id = int(cell_xfs_node.get('numFmtId'))
  if (number_format_id < 164):
   new_style.number_format.format_code = builtin_formats.get(number_format_id, 'General')
  elif (number_format_id in custom_num_formats):
   new_style.number_format.format_code = custom_num_formats[number_format_id]
  else:
   raise MissingNumberFormat(('%s' % number_format_id))
  table[index] = new_style
 return table

def read_style_table ( xml_source ) : table = { } xmlns = 'http://schemas.openxmlformats.org/spreadsheetml/2006/main' root = fromstring ( xml_source ) custom_num_formats = parse_custom_num_formats ( root , xmlns ) builtin_formats = NumberFormat . _BUILTIN_FORMATS cell_xfs = root . find ( QName ( xmlns , 'cellXfs' ) . text ) cell_xfs_nodes = cell_xfs . findall ( QName ( xmlns , 'xf' ) . text ) for ( index , cell_xfs_node ) in enumerate ( cell_xfs_nodes ) : new_style = Style ( ) number_format_id = int ( cell_xfs_node . get ( 'numFmtId' ) ) if ( number_format_id < 164 ) : new_style . number_format . format_code = builtin_formats . get ( number_format_id , 'General' ) elif ( number_format_id in custom_num_formats ) : new_style . number_format . format_code = custom_num_formats [ number_format_id ] else : raise MissingNumberFormat ( ( '%s' % number_format_id ) ) table [ index ] = new_style return table
read styles from the shared style table .