Php 键入3文件下载(CSV)错误
我正在用Typ3扩展名生成一个csv文件,但在我的csv文件中有一些神秘的行Php 键入3文件下载(CSV)错误,php,csv,typo3,extbase,typo3-6.2.x,Php,Csv,Typo3,Extbase,Typo3 6.2.x,我正在用Typ3扩展名生成一个csv文件,但在我的csv文件中有一些神秘的行 <p><strong>Sorry, the requested view was not found.</strong></p> <p>The technical reason is: <em>No template was found. View could not be resolved for acti
<p><strong>Sorry, the requested view was not found.</strong></p>
<p>The technical reason is: <em>No template was found. View could not be resolved for action "exportPrueflinge" in class "ReRe\Rere\Controller\ExportController"</em>.</p>
我能做些什么来避免这两条错误的线路?它们位于csv文件的末尾。这听起来有点脏,但请尝试在Templates/Export中创建名为exportPrueflinge.html的视图模板 必须添加
返回FALSE
在genCSV()函数的末尾,则模板呈现错误消息将不会添加到CSV文件。没有此列表的视图。我从存储库中收集所需的数据,然后编写csv文件。或者我应该在普通视图中写入内容?但我不希望csv文件显示。。。我只想下载它这么简单。。。谢谢!很好!但是“返回错误;”必须在控制器中
public function genCSV($array, $filename) {
// Anlegen eine termporären datei mit Schreibrechten
$fp = null;
$fp = fopen('php://memory', 'w');
// Array in CSV übertragen
foreach ($array as $fields) {
fputcsv($fp, $fields, ";");
}
rewind($fp);
header('Cache-Control: no-cache, must-revalidate');
header('Pragma: no-cache');
header('Content-Type: application/csv');
header('Content-Disposition: attachement; filename="' . $filename . '";');
// Download starten
fpassthru($fp);
}