You are here

public function webform_exporter_excel_xlsx::eof in Webform 7.4

Output the BOF and end the file.

We output a chunk of empty data in webform_exporter_excel_xlsx::bof() to leave room for our real header, which includes the important <dimension> tag. This is required for proper importing into Google Docs.

Overrides webform_exporter::eof

File

includes/exporters/webform_exporter_excel_xlsx.inc, line 121

Class

webform_exporter_excel_xlsx
This exporter creates an XLSX file readable by newer versions of Excel.

Code

public function eof(&$file_handle, $row_count, $col_count) {

  // Convert column count to letter representation.
  $col = 'A';
  for ($n = 1; $n < $col_count; $n++) {
    $col++;
  }
  $bof = '';
  $bof .= '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' . "\n";
  $bof .= '<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">';
  $bof .= '<dimension ref="A1:' . $col . $row_count . '"/>';
  $bof .= '<sheetData>';
  @fseek($file_handle, 0);
  @fwrite($file_handle, $bof);
  $eof = '';
  $eof .= '</sheetData>';
  $eof .= '</worksheet>';
  fseek($file_handle, 0, SEEK_END);
  fwrite($file_handle, $eof);
}