You are here

function ViewsDataExportExporterExcelxlsx::eof in Views data export 7.4

Write the end of the export file.

Parameters

$file_handle: A PHP file handle to the export file.

Overrides ViewsDataExportExporter::eof

File

exporters/views_data_export_exporter_excel_xlsx.inc, line 113

Class

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

Code

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

  // 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.
  // 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);
}