0
我想创建一个word文件作为报告。我想从表格中提取所有数据并放到word文件中,但我无法将数据保存到文件中。我在laravel 5.2中做了。文件正在创建和下载,但来自数据库的数据没有保存。感谢大家 这里是我的控制器代码 -如何将数据保存在laravel数据库的word文件中
public function downloadAbleFile(Request $request){
//Fetching all records based on projectid
$project_id = $request->input('project_id');
$questiondetails = DB::table('questionnair')->where('project_id','=',$project_id)->get();
$headers = array(
"Content-type"=>"text/html",
"Content-Disposition"=>"attachment;Filename=report.doc"
);
$content = '<html>
<head>
<meta charset="utf-8">
</head>
<body>
<p>
<table>
<thead>
<tr>
<th>Project ID</th>
<th>Question Number</th>
<th>User ID</th>
<th>Answer</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<?php
function project(){
foreach ($questiondetails as $question){
return(
echo "<tr>";
echo "<td>".$question->project_id."</td>";
echo "<td>".$question->question_num."</td>";
echo "<td>".$question->user_id."</td>";
echo "<td>".$question->answer."</td>";
echo "<td>".$question->status."</td>";
echo "</tr>";
);
}
}
project();
?>
</tbody>
</table>
</p>
</body>
</html>';
return Response::make($content,200, $headers);
}