class_docstr: Class for formatting a DataFrame to a list of ExcelCells,
  
  Parameters
  ----------
  df : DataFrame or Styler
  na_rep: na representation
  float_format : str, default None
      Format string for floating point numbers
  cols : sequence, optional
      Columns to write
  header : bool or sequence of str, default True
      Write out column names. If a list of string is given it is
      assumed to be aliases for the column names
  index : bool, default True
      output row names (index)
  index_label : str 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 : bool, default False
      Format MultiIndex and Hierarchical Rows as merged cells.
  inf_rep : str, 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.
class_docstr_tok: ["Class","for","formatting","a","DataFrame","to","a","list","of","ExcelCells",",","Parameters","--","--","--","--","--","df",":","DataFrame","or","Styler","na_rep",":","na","representation","float_format",":","str",",","default","None","Format","string","for","floating","point","numbers","cols",":","sequence",",","optional","Columns","to","write","header",":","bool","or","sequence","of","str",",","default","True","Write","out","column","names",".","If","a","list","of","string","is","given","it","is","assumed","to","be","aliases","for","the","column","names","index",":","bool",",","default","True","output","row","names","(","index",")","index_label",":","str","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",":","bool",",","default","False","Format","MultiIndex","and","Hierarchical","Rows","as","merged","cells",".","inf_rep",":","str",",","default","`","'inf","'","`","representation","for","np.inf","values","(","which","are","n'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_value(self, val):
      if is_scalar(val) and missing.isna(val):
          val = self.na_rep
      elif is_float(val):
          if missing.isposinf_scalar(val):
              val = self.inf_rep
          elif missing.isneginf_scalar(val):
              val = f"-{self.inf_rep}"
          elif self.float_format is not None:
              val = float(self.float_format % val)
      if getattr(val, "tzinfo", None) is not None:
          raise ValueError(
              "Excel does not support datetimes with "
              "timezones. Please ensure that datetimes "
              "are timezone unaware before writing to Excel."
          )
      return val
  
imports: from __future__ import annotations
  from functools import lru_cache, reduce
  import itertools
  import re
  from typing import Any, Callable, Hashable, Iterable, Mapping, Sequence, cast
  import warnings
  import numpy
  from pandas._libs.lib import is_list_like
  from pandas._typing import IndexLabel, StorageOptions
  from pandas.util._decorators import doc
  from pandas.util._exceptions import find_stack_level
  from pandas.core.dtypes import missing
  from pandas.core.dtypes.common import is_float, is_scalar
  from pandas import DataFrame, Index, MultiIndex, PeriodIndex
  import pandas.core.common
  from pandas.core.shared_docs import _shared_docs
  from pandas.io.formats._color_data import CSS4_COLORS
  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 3 for calling the ExcelFormatter obj's underlying member method code with example usage: obj._format_value(val) and returns: val