class_docstr: Internal class for formatting output data in html.
  This class is intended for shared functionality between
  DataFrame.to_html() and DataFrame._repr_html_().
  Any logic in common with other output formatting methods
  should ideally be inherited from classes in format.py
  and this class responsible for only producing html markup.
code: def _write_col_header(self, indent: int) -> None:
      row: list[Hashable]
      is_truncated_horizontally = self.fmt.is_truncated_horizontally
      if isinstance(self.columns, MultiIndex):
          template = 'colspan="{span:d}" halign="left"'
  
          sentinel: lib.NoDefault | bool
          if self.fmt.sparsify:
              # GH3547
              sentinel = lib.no_default
          else:
              sentinel = False
          levels = self.columns._format_multi(
              sparsify=sentinel, include_names=False
          )
          level_lengths = get_level_lengths(levels, sentinel)
          inner_lvl = len(level_lengths) - 1
          for lnum, (records, values) in enumerate(
              zip(level_lengths, levels)
          ):
              if is_truncated_horizontally:
                  # modify the header lines
                  ins_col = self.fmt.tr_col_num
                  if self.fmt.sparsify:
                      recs_new = {}
                      # Increment tags after ... col.
                      for tag, span in list(records.items()):
                          if tag >= ins_col:
                              recs_new[tag + 1] = span
                          elif tag + span > ins_col:
                              recs_new[tag] = span + 1
                              if lnum == inner_lvl:
                                  values = (
                                      values[:ins_col]
                                      + ("...",)
                                      + values[ins_col:]
                                  )
                              else:
                                  # sparse col headers do not receive a ...
                                  values = (
                                      values[:ins_col]
                                      + (values[ins_col - 1],)
                                      + values[ins_col:]
                                  )
                          else:
                              recs_new[tag] = span
                          # if ins_col lies between tags, all col headers
                          # get ...
                          if tag + span == ins_col:
                              recs_new[ins_col] = 1
                              values = (
                                  values[:ins_col]
                                  + ("...",)
                                  + values[ins_col:]
                              )
                      records = recs_new
                      inner_lvl = len(level_lengths) - 1
                      if lnum == inner_lvl:
                          records[ins_col] = 1
                  else:
                      recs_new = {}
                      for tag, span in list(records.items()):
                          if tag >= ins_col:
                              recs_new[tag + 1] = span
                          else:
                              recs_new[tag] = span
                      recs_new[ins_col] = 1
                      records = recs_new
                      values = (
                          values[:ins_col] + ["..."] + values[ins_col:]
                      )
  
              # see gh-22579
              # Column Offset Bug with to_html(index=False) with
              # MultiIndex Columns and Index.
              # Initially fill row with blank cells before column names.
              # TODO: Refactor to remove code duplication with code
              # block below for standard columns index.
              row = [""] * (self.row_levels - 1)
              if self.fmt.index or self.show_col_idx_names:
                  # see gh-22747
                  # If to_html(index_names=False) do not show columns
                  # index names.
                  # TODO: Refactor to use _get_column_name_list from
                  # DataFrameFormatter class and create a
                  # _get_formatted_column_labels function for code
                  # parity with DataFrameFormatter class.
                  if self.fmt.show_index_names:
                      name = self.columns.names[lnum]
                      row.append(pprint_thing(name or ""))
                  else:
                      row.append("")
  
              tags = {}
              j = len(row)
              for i, v in enumerate(values):
                  if i in records:
                      if records[i] > 1:
                          tags[j] = template.format(span=records[i])
                  else:
                      continue
                  j += 1
                  row.append(v)
              self.write_tr(
                  row, indent, self.indent_delta, tags=tags, header=True
              )
      else:
          # see gh-22579
          # Column misalignment also occurs for
          # a standard index when the columns index is named.
          # Initially fill row with blank cells before column names.
          # TODO: Refactor to remove code duplication with code block
          # above for columns MultiIndex.
          row = [""] * (self.row_levels - 1)
          if self.fmt.index or self.show_col_idx_names:
              # see gh-22747
              # If to_html(index_names=False) do not show columns
              # index names.
              # TODO: Refactor to use _get_column_name_list from
              # DataFrameFormatter class.
              if self.fmt.show_index_names:
                  row.append(self.columns.name or "")
              else:
                  row.append("")
          row.extend(self._get_columns_formatted_values())
          align = self.fmt.justify
  
          if is_truncated_horizontally:
              ins_col = self.row_levels + self.fmt.tr_col_num
              row.insert(ins_col, "...")
  
          self.write_tr(
              row, indent, self.indent_delta, header=True, align=align
          )
  
imports: from __future__ import annotations
  from textwrap import dedent
  from typing import TYPE_CHECKING, Any, Final, cast
  from pandas._config import get_option
  from pandas._libs import lib
  from pandas import MultiIndex, option_context
  from pandas.io.common import is_url
  from pandas.io.formats.format import DataFrameFormatter, get_level_lengths
  from pandas.io.formats.printing import pprint_thing
label_desc: Use image node_id 17 for calling the HTMLFormatter obj's underlying member method code with example usage: obj._write_col_header(indent) without return types