'write styles combinations based on ids found in tables'

def _write_cell_xfs(self, number_format_table, fonts_table, fills_table, borders_table):

    cell_xfs = SubElement(self._root, 'cellXfs', {'count': ('%d' % (len(self._style_list) + 1))})
    def _get_default_vals():
        return dict(numFmtId='0', fontId='0', fillId='0', xfId='0', borderId='0')
    SubElement(cell_xfs, 'xf', _get_default_vals())
    for st in self._style_list:
        vals = _get_default_vals()
        if (hash(st.font) != hash(style.DEFAULTS.font)):
            vals['fontId'] = fonts_table[hash(st.font)]
            vals['applyFont'] = '1'
        if (hash(st.borders) != hash(style.DEFAULTS.borders)):
            vals['borderId'] = borders_table[hash(st.borders)]
            vals['applyBorder'] = '1'
        if (hash(st.fill) != hash(style.DEFAULTS.fill)):
            vals['fillId'] = fills_table[hash(st.fill)]
            vals['applyFillId'] = '1'
        if (st.number_format != style.DEFAULTS.number_format):
            vals['numFmtId'] = ('%d' % number_format_table[st.number_format])
            vals['applyNumberFormat'] = '1'
        if (hash(st.alignment) != hash(style.DEFAULTS.alignment)):
            vals['applyAlignment'] = '1'
        node = SubElement(cell_xfs, 'xf', vals)
        if (hash(st.alignment) != hash(style.DEFAULTS.alignment)):
            alignments = {}
            for align_attr in ['horizontal', 'vertical']:
                if (hash(getattr(st.alignment, align_attr)) != hash(getattr(style.DEFAULTS.alignment, align_attr))):
                    alignments[align_attr] = getattr(st.alignment, align_attr)
            SubElement(node, 'alignment', alignments)
