Zend Framework: View File downloaded as Excel File
Filed Under (General) by Wenbert on 02-04-2008
Tagged Under : excel, Zend Framework
This is basically a back-up post from my previous posts regarding exporting of data from a database to an excel file. Since Excel is able to read HTML tables, we can directly export a “view” file into an excel file by changing the headers of the request.
-
-
< ?php
-
?>
-
-
< html>
-
< body>
-
< table border="1">
-
< tr>
-
< th>Employee ID< / th>
-
< th>Employee Name< / th>
-
< /tr>
-
< ?php
-
foreach ($data AS $row) :
-
?>
-
< tr>
-
< td>< ?=$row[‘employee_id’]?>< / td>
-
< td>< ?=$row[‘employee_name’]?>< / td>
-
< / tr>
-
< ?php
-
endforeach;
-
?>
-
< / table>
-
< / body>
-
< / html>
-
It is important that you disable layouts and other stuff that will directly change the output of the view file.