code: private function writeChartInCell(Worksheet $pSheet, $coordinates)
      {
          // Construct HTML
          $html = '';
  
          // Write charts
          foreach ($pSheet->getChartCollection() as $chart) {
              if ($chart instanceof Chart) {
                  $chartCoordinates = $chart->getTopLeftPosition();
                  if ($chartCoordinates['cell'] == $coordinates) {
                      $chartFileName = File::sysGetTempDir() . '/' . uniqid('', true) . '.png';
                      if (!$chart->render($chartFileName)) {
                          return;
                      }
  
                      $html .= PHP_EOL;
                      $imageDetails = getimagesize($chartFileName);
                      if ($fp = fopen($chartFileName, 'rb', 0)) {
                          $picture = fread($fp, filesize($chartFileName));
                          fclose($fp);
                          // base64 encode the binary data, then break it
                          // into chunks according to RFC 2045 semantics
                          $base64 = chunk_split(base64_encode($picture));
                          $imageData = 'data:' . $imageDetails['mime'] . ';base64,' . $base64;
  
                          $html .= '<div style="position: relative;">';
                          $html .= '<img style="position: absolute; z-index: 1; left: ' . $chartCoordinates['xOffset'] . 'px; top: ' . $chartCoordinates['yOffset'] . 'px; width: ' . $imageDetails[0] . 'px; height: ' . $imageDetails[1] . 'px;" src="' . $imageData . '" border="0" />' . PHP_EOL;
                          $html .= '</div>';
  
                          unlink($chartFileName);
                      }
                  }
              }
          }
  
          // Return
          return $html;
      }
docs: Generate chart tag in cell.
  
  @param Worksheet $pSheet \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet
  @param string $coordinates Cell coordinates
  
  @return string