In this
tutorial we will discuss about
export data to
Excel in PHP. We will create this project because many places in our project we are needed to
provide export to Excel functionality. So the user can easily
access and
view their
data through an
excel file. With the script shows below you can easily implement the export data to Excel functionality using PHP.
Sample Code
For The Function of exporting the data in a .ms-excel format.
<php>function filterData(&$str)
{
}
$fileName = "excelexport" . date('Ymd') . ".xls"; header("Content-Disposition: attachment; filename=\"$fileName\""); header("Content-Type: application/.ms-excel");
$flag = false;
foreach($data as $row) {
if(!$flag) {
$flag = true;
}
}
?>
And for the Data Array Script for exporting the data through Excel file.
<?php
array("First Name" => "Reynan", "Last Name" => "Serion", "Email" => "[email protected]", "Message" => "Message For Reynan"), array("First Name" => "Rolyn Jasper", "Last Name" => "Demirin", "Email" => "[email protected]", "Message" => "Message For Rolyn Jasper"), array("First Name" => "Jasper", "Last Name" => "Claro", "Email" => "[email protected]", "Message" => "Message For Jasper"), array("First Name" => "Rocky", "Last Name" => "Basa", "Email" => "[email protected]", "Message" => "Message For Rocky") array("First Name" => "Van-Van", "Last Name" => "Nav", "Email" => "[email protected]", "Message" => "Message For Van-Van") );
?>
Hope that you learn in this tutorial and enjoy coding. Don't forget to
LIKE &
SHARE this website. If you do have any
problems or
suggestions in your projects or programming, then just visit this website
http://www.sourcecodester.com/ for more updates and programming ideas.