class_docstr: Class for formatting a DataFrame to a list of ExcelCells,
  
  Parameters
  ----------
  df : DataFrame or Styler
  na_rep: na representation
  float_format : string, default None
          Format string for floating point numbers
  cols : sequence, optional
      Columns to write
  header : boolean or list of string, default True
      Write out column names. If a list of string is given it is
      assumed to be aliases for the column names
  index : boolean, default True
      output row names (index)
  index_label : string or sequence, default None
          Column label for index column(s) if desired. If None is given, and
          `header` and `index` are True, then the index names are used. A
          sequence should be given if the DataFrame uses MultiIndex.
  merge_cells : boolean, default False
          Format MultiIndex and Hierarchical Rows as merged cells.
  inf_rep : string, default `'inf'`
      representation for np.inf values (which aren't representable in Excel)
      A `'-'` sign will be added in front of -inf.
  style_converter : callable, optional
      This translates Styler styles (CSS) into ExcelWriter styles.
      Defaults to ``CSSToExcelConverter()``.
      It should have signature css_declarations string -> excel style.
      This is only called for body cells.
code: def _format_header_mi(self):
      if self.columns.nlevels > 1:
          if not self.index:
              raise NotImplementedError(
                  "Writing to Excel with MultiIndex"
                  " columns and no index "
                  "('index'=False) is not yet "
                  "implemented."
              )
  
      has_aliases = isinstance(
          self.header, (tuple, list, np.ndarray, Index)
      )
      if not (has_aliases or self.header):
          return
  
      columns = self.columns
      level_strs = columns.format(
          sparsify=self.merge_cells, adjoin=False, names=False
      )
      level_lengths = get_level_lengths(level_strs)
      coloffset = 0
      lnum = 0
  
      if self.index and isinstance(self.df.index, ABCMultiIndex):
          coloffset = len(self.df.index[0]) - 1
  
      if self.merge_cells:
          # Format multi-index as a merged cells.
          for lnum in range(len(level_lengths)):
              name = columns.names[lnum]
              yield ExcelCell(lnum, coloffset, name, self.header_style)
  
          for lnum, (spans, levels, level_codes) in enumerate(
              zip(level_lengths, columns.levels, columns.codes)
          ):
              values = levels.take(level_codes)
              for i in spans:
                  if spans[i] > 1:
                      yield ExcelCell(
                          lnum,
                          coloffset + i + 1,
                          values[i],
                          self.header_style,
                          lnum,
                          coloffset + i + spans[i],
                      )
                  else:
                      yield ExcelCell(
                          lnum,
                          coloffset + i + 1,
                          values[i],
                          self.header_style,
                      )
      else:
          # Format in legacy format with dots to indicate levels.
          for i, values in enumerate(zip(*level_strs)):
              v = ".".join(map(pprint_thing, values))
              yield ExcelCell(
                  lnum, coloffset + i + 1, v, self.header_style
              )
  
      self.rowcounter = lnum
  
imports: import itertools
  import re
  import warnings
  import numpy
  from pandas.compat import reduce
  from pandas.core.dtypes import missing
  from pandas.core.dtypes.common import is_float, is_scalar
  from pandas.core.dtypes.generic import ABCMultiIndex, ABCPeriodIndex
  from pandas import Index
  import pandas.core.common
  from pandas.io.formats.css import CSSResolver, CSSWarning
  from pandas.io.formats.format import get_level_lengths
  from pandas.io.formats.printing import pprint_thing
label_desc: Use image node_id 4 for calling the ExcelFormatter obj's underlying member method code with example usage: obj._format_header_mi() without return types