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","."]
docstr: writer : path-like, file-like, or ExcelWriter object
      File path or existing ExcelWriter
  sheet_name : str, default 'Sheet1'
      Name of sheet which will contain DataFrame
  startrow :
      upper left cell row to dump data frame
  startcol :
      upper left cell column to dump data frame
  freeze_panes : tuple of integer (length 2), default None
      Specifies the one-based bottommost row and rightmost column that
      is to be frozen
  engine : string, default None
      write engine to use if writer is a path - you can also set this
      via the options ``io.excel.xlsx.writer``,
      or ``io.excel.xlsm.writer``.
  
  {storage_options}
  
      .. versionadded:: 1.2.0
docstr_tok: ["writer",":","path-like",",","file-like",",","or","ExcelWriter","object","File","path","or","existing","ExcelWriter","sheet_name",":","str",",","default","'Sheet1'","Name","of","sheet","which","will","contain","DataFrame","startrow",":","upper","left","cell","row","to","dump","data","frame","startcol",":","upper","left","cell","column","to","dump","data","frame","freeze_panes",":","tuple","of","integer","(","length","2",")",",","default","None","Specifies","the","one-based","bottommost","row","and","rightmost","column","that","is","to","be","frozen","engine",":","string",",","default","None","write","engine","to","use","if","writer","is","a","path","-","you","can","also","set","this","via","the","options","``","io.excel.xlsx.writer","``",",","or","``","io.excel.xlsm.writer","``",".","{","storage_options","}","..","versionadded",":",":","1.2.0"]
code: def write(
      self,
      writer,
      sheet_name: str = "Sheet1",
      startrow: int = 0,
      startcol: int = 0,
      freeze_panes: tuple[int, int] | None = None,
      engine: str | None = None,
      storage_options: StorageOptions = None,
  ) -> None:
      """
      writer : path-like, file-like, or ExcelWriter object
          File path or existing ExcelWriter
      sheet_name : str, default 'Sheet1'
          Name of sheet which will contain DataFrame
      startrow :
          upper left cell row to dump data frame
      startcol :
          upper left cell column to dump data frame
      freeze_panes : tuple of integer (length 2), default None
          Specifies the one-based bottommost row and rightmost column that
          is to be frozen
      engine : string, default None
          write engine to use if writer is a path - you can also set this
          via the options ``io.excel.xlsx.writer``,
          or ``io.excel.xlsm.writer``.
  
      {storage_options}
  
          .. versionadded:: 1.2.0
      """
      from pandas.io.excel import ExcelWriter
  
      num_rows, num_cols = self.df.shape
      if num_rows > self.max_rows or num_cols > self.max_cols:
          raise ValueError(
              f"This sheet is too large! Your sheet size is: {num_rows}, {num_cols} "
              f"Max sheet size is: {self.max_rows}, {self.max_cols}"
          )
  
      formatted_cells = self.get_formatted_cells()
      if isinstance(writer, ExcelWriter):
          need_save = False
      else:
          # error: Cannot instantiate abstract class 'ExcelWriter' with abstract
          # attributes 'engine', 'save', 'supported_extensions' and 'write_cells'
          writer = ExcelWriter(  # type: ignore[abstract]
              writer, engine=engine, storage_options=storage_options
          )
          need_save = True
  
      try:
          writer._write_cells(
              formatted_cells,
              sheet_name,
              startrow=startrow,
              startcol=startcol,
              freeze_panes=freeze_panes,
          )
      finally:
          # make sure to close opened file handles
          if need_save:
              writer.close()
  
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 13 for calling the ExcelFormatter obj's underlying member method code with example usage: obj.write(writer, sheet_name, startrow, startcol, freeze_panes, engine, storage_options) without return types