コード例 #1
0
 /**
  * Export to Excel
  *
  * @param \Sng\Recordsmanager\Utility\Query $query
  */
 public function exportToEXCEL(\Sng\Recordsmanager\Utility\Query $query)
 {
     $rows = array_merge(array($query->getHeaders()), $query->getRows());
     $dirName = PATH_site . 'typo3temp/';
     $filename = 'TYPO3_' . $query->getFrom() . '_export_' . date('dmy-Hi') . '.xls';
     require_once PATH_site . "typo3conf/ext/recordsmanager/Resources/Private/Php/php_writeexcel-0.3.0/class.writeexcel_workbook.inc.php";
     require_once PATH_site . "typo3conf/ext/recordsmanager/Resources/Private/Php/php_writeexcel-0.3.0/class.writeexcel_worksheet.inc.php";
     $fname = $dirName . $filename;
     $workbook = new \writeexcel_workbook($fname);
     $worksheet = $workbook->addworksheet();
     $header = $workbook->addformat();
     $header->set_bold();
     $header->set_size(12);
     $line = 0;
     foreach ($rows as $row) {
         $col = 0;
         foreach ($row as $field => $value) {
             $value = self::cleanString($value);
             if ($line == 0) {
                 $worksheet->write($line, $col++, $value, $header);
             } else {
                 if (is_numeric($value)) {
                     $value = $value . " ";
                 }
                 $worksheet->write($line, $col++, $value);
             }
         }
         $line++;
     }
     $workbook->close();
     header("Content-Type: application/x-msexcel; name=\"" . $filename . "\"");
     header("Content-Disposition: inline; filename=\"" . $filename . "\"");
     $fh = fopen($fname, "rb");
     fpassthru($fh);
     unlink($fname);
     exit;
 }
コード例 #2
0
ファイル: Index.php プロジェクト: Apen/recordsmanager
 /**
  * Export to JSON
  *
  * @param \Sng\Recordsmanager\Utility\Query $query
  */
 public function exportToJson(\Sng\Recordsmanager\Utility\Query $query)
 {
     echo json_encode($query->getRows());
 }