Monday, June 3, 2013
Export excel sheet code in php
$query = "SELECT `name` , `dob` , `gender` , `email` ,
`mobile` , `street` , `city` , `state` , `postalcode` , `country` ,
`applied` , `appliedmonth` , `appliedyear` ,
`tenthcourse` , `tenthpercent` , `twelvethcourse` , `twelvethpercent` , `graduationcourse` , `graduationpercent` ,
`pgcourse` , `pgpercent` , `haveexperience` , `expinmonth` ,
`currentemployer` , `currentdesig` , `durationinmonth` , `currentsalary` , `expectedsalary` ,
`appliedposition` , `resume` FROM `applyonline` order by `id` DESC";
$result = mysql_query($query) or die(mysql_error());
$tsv = array();
$html = array();
//////////////////////////////top heading in excel file////////////////////////////////////////////
//$tsv[] = "<B>APPLIED CANDIDATES REPORT</B>";
//$html[] = "<tr>" ."<td>"."<B>APPLIED CANDIDATES REPORT</B>"."</td></tr>";
$tsv[] = "<B>Name</B>";
$html[] = "<tr>" ."<td>"."<B>Name</B>"."</td>";
$tsv[] = "<B>DOB</B>";
$html[] = "<td>"."<B>DOB</B>"."</td>";
$tsv[] = "<B>Gender</B>";
$html[] = "<td>"."<B>Gender</B>"."</td>";
/* $tsv[] = "<B>City of work</B>";
$html[] = "<td>"."<B>City of work</B>"."</td>";
*/
$tsv[] = "<B>Email</B>";
$html[] = "<td>"."<B>Email</B>"."</td>";
$tsv[] = "<B>Mobile</B>";
$html[] = "<td>"."<B>Mobile</B>"."</td>";
$tsv[] = "<B>Street</B>";
$html[] = "<td>"."<B>Street</B>"."</td>";
$tsv[] = "<B>City</B>";
$html[] = "<td>"."<B>City</B>"."</td>";
$tsv[] = "<B>State</B>";
$html[] = "<td>"."<B>State</B>"."</td>";
$tsv[] = "<B>Postal Code</B>";
$html[] = "<td>"."<B>Postal Code</B>"."</td>";
$tsv[] = "<B>Country</B>";
$html[] = "<td>"."<B>Country</B>"."</td>";
$tsv[] = "<B>Applied</B>";
$html[] = "<td>"."<B>Applied</B>"."</td>";
$tsv[] = "<B>Applied Month</B>";
$html[] = "<td>"."<B>Applied Month</B>"."</td>";
$tsv[] = "<B>Applied Year</B>";
$html[] = "<td>"."<B>Applied Year</B>"."</td>";
$tsv[] = "<B>Xth Course</B>";
$html[] = "<td>"."<B>Xth Course</B>"."</td>";
$tsv[] = "<B>Xth Percent</B>";
$html[] = "<td>"."<B>Xth Percent</B>"."</td>";
$tsv[] = "<B>XIIth Course</B>";
$html[] = "<td>"."<B>XIIth Course</B>"."</td>";
$tsv[] = "<B>XIIth Percent</B>";
$html[] = "<td>"."<B>XIIth Percent</B>"."</td>";
$tsv[] = "<B>Graduation Course</B>";
$html[] = "<td>"."<B>Graduation Course</B>"."</td>";
$tsv[] = "<B>Graduation Percent</B>";
$html[] = "<td>"."<B>Graduation Percent</B>"."</td>";
$tsv[] = "<B>PG Course</B>";
$html[] = "<td>"."<B>PG Course</B>"."</td>";
$tsv[] = "<B>PG Percent</B>";
$html[] = "<td>"."<B>PG Percent</B>"."</td>";
$tsv[] = "<B>Have Experience</B>";
$html[] = "<td>"."<B>Have Experience</B>"."</td>";
$tsv[] = "<B>Exp. in Month</B>";
$html[] = "<td>"."<B>Exp. in Month</B>". "</td>";
$tsv[] = "<B>Current Employer</B>";
$html[] = "<td>"."<B>Current Employer</B>"."</td>";
$tsv[] = "<B>Current Designation</B>";
$html[] = "<td>"."<B>Current Designation</B>"."</td>";
$tsv[] = "<B>Duration in Month</B>";
$html[] = "<td>"."<B>Duration in Month</B>"."</td>";
$tsv[] = "<B>Current Salary</B>";
$html[] = "<td>"."<B>Current Salary</B>"."</td>";
$tsv[] = "<B>Expected Salary</B>";
$html[] = "<td>"."<B>Expected Salary</B>"."</td>";
$tsv[] = "<B>Applied Position</B>";
$html[] = "<td>"."<B>Applied Position</B>"."</td>";
$tsv[] = "<B>Resume</B>";
$html[] = "<td>"."<B>Resume</B>"."</td></tr>";
///////////////////////////////////////////////////////////////////////////////////////////////////
while($row = mysql_fetch_array($result, MYSQL_NUM))
{
$tsv[] = implode("\t", $row);
$html[] = "<tr><td>" .implode("</td><td>", $row) ."</td></tr>";
}
$tsv = implode("\r\n", $tsv);
$html = "<table border=1>" . implode("\r\n", $html) . "</table>";
$fileName = 'report.xls';
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=$fileName");
//echo $tsv;
echo $html;
Subscribe to:
Post Comments (Atom)
Popular Posts
-
Variables are important in every programming language — and it’s no different in PHP. Variables give developers the possibility of temp...
-
What? Hide the .php extension of your PHP files in the URL of your site address. Instead of: http://www.example.com/page.php Visitors to ...
-
Questions : 1 Who is the father of PHP ? Answers : 1 Rasmus Lerdorf is known as the father of PHP. Questions : 2 What is the...
-
Change Db settings here C:\xampp\htdocs\modx\core\xpdo\xpdo.class Line 2920 $this->config['dsn']= $dsn; $this->con...
-
<form action="" name="" method="post"> <p><b>user:</b> <input type="text...
-
Redirection is process of forwarding one URL to a different URL. There are three main kinds of redirects online; 301, 302 and meta refres...
-
Questions : 1 What is database or database management systems (DBMS)? and - What’s the difference between file and database? Can files...
-
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script...
-
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Add More Elements...
No comments:
Post a Comment
Thank you for your Comment....