I am using HTml2pdf library to convert HTML to PDF.
Below is the code i am using.
PHP
require __DIR__.'/vendor/autoload.php';
use Spipu\Html2Pdf\Html2Pdf;
$html2pdf = new Html2Pdf();
$html2pdf = new HTML2PDF('P', 'A4', 'en');
$html2pdf->setTestTdInOnePage(false);
$html = file_get_contents('index.html');
$html2pdf->writeHTML($html);
$html2pdf->output();
HTML
<div class="bap">
<div class="row">
<div class="par_col">
<div class="column">
<img src="b.jpg" alt="test">
<table style="width:99%" class="feetop">
<tr>
<td class="t_head">Challan No.</td>
<td class="lii undl">18584</td>
<td class="t_heada">Due Date:</td>
<td class="liia undl"></td>
</tr>
<tr>
<td class="t_head_c">Name</td>
<td colspan="3" class="lii undl">Hamza Zafeer</td>
</tr>
<tr>
<td>Program:</td>
<td class="lii undl de">BS Civil Tech </td>
<td >Roll No.</td>
<td class="undl"></td>
</tr>
<tr>
<td>Semester</td>
<td class="undl"></td>
<td>Session</td>
<td class="undl">2018-2021</td>
</tr>
</table>
<table style="width:99%" class="fee">
<tr>
<th >PARTICULARS</th>
<th>Rs.</th>
<th>Ps.</th>
</tr>
<tr>
<td>Registration Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Admission Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Tuition Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Laboratory Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Library Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Transcript / Degree Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Examination Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Security Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Hostel Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Transport charges</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Fine</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Misc.</td>
<td>1000</td>
<td></td>
</tr>
<tr>
<td>Total Payable</td>
<td>1000</td>
<td></td>
</tr>
</table>
<div class="btm">
<div class="fm rss"><strong>Rs. in words :</strong> One thousand only</div>
<div class="fm bt"> Cashier</div>
</div>
</div></div>
<div class="par_col">
<div class="column">
<img src="a.jpg" alt="test">
<table style="width:99%" class="feetop">
<tr>
<td class="t_head">Challan No.</td>
<td class="lii undl">18584</td>
<td class="t_heada">Due Date:</td>
<td class="liia undl"></td>
</tr>
<tr>
<td class="t_head_c">Name</td>
<td colspan="3" class="lii undl">Hamza Zafeer</td>
</tr>
<tr>
<td>Program:</td>
<td class="lii undl de">BS Civil Tech </td>
<td >Roll No.</td>
<td class="undl"></td>
</tr>
<tr>
<td>Semester</td>
<td class="undl"></td>
<td>Session</td>
<td class="undl">2018-2021</td>
</tr>
</table>
<table style="width:99%" class="fee">
<tr>
<th >PARTICULARS</th>
<th>Rs.</th>
<th>Ps.</th>
</tr>
<tr>
<td>Registration Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Admission Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Tuition Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Laboratory Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Library Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Transcript / Degree Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Examination Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Security Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Hostel Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Transport charges</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Fine</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Misc.</td>
<td>1000</td>
<td></td>
</tr>
</table>
<div class="btm">
<div class="fm rss"><strong>Rs. in words :</strong> One thousand only</div>
<div class="fm bt"> Cashier</div>
</div>
</div></div>
<div class="par_col">
<div class="column">
<img src="s.jpg" alt="test">
<table style="width:99%" class="feetop">
<tr>
<td class="t_head">Challan No.</td>
<td class="lii undl">18584</td>
<td class="t_heada">Due Date:</td>
<td class="liia undl"></td>
</tr>
<tr>
<td class="t_head_c">Name</td>
<td colspan="3" class="lii undl">Hamza Zafeer</td>
</tr>
<tr>
<td>Program:</td>
<td class="lii undl de">BS Civil Tech </td>
<td >Roll No.</td>
<td class="undl"></td>
</tr>
<tr>
<td>Semester</td>
<td class="undl"></td>
<td>Session</td>
<td class="undl">2018-2021</td>
</tr>
</table>
<table style="width:99%" class="fee">
<tr>
<th >PARTICULARS</th>
<th>Rs.</th>
<th>Ps.</th>
</tr>
<tr>
<td>Registration Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Admission Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Tuition Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Laboratory Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Library Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Transcript / Degree Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Examination Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Security Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Hostel Fee</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Transport charges</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Fine</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Misc.</td>
<td>1000</td>
<td></td>
</tr>
</table>
<div class="btm">
<div class="fm rss"><strong>Rs. in words :</strong> One thousand only</div>
<div class="fm bt"> Cashier</div>
</div>
</div></div>
OUTPUT of HTML
But When i generate PDF, each section converted into a single page, and final PDF consisted on 3 pages.
Problem
It should not generate the 3 pages of PDF. Anybody can tell me what i am doing wrong, why it is creates 3 pages instead of 1 page?
I think it lacks the space, try to wrap your tables in one more table, like:
<table>
<tr>
<td>%table1HTML%</td>
</tr>
<tr>
<td>%table2HTML%</td>
</tr>
<tr>
<td>%table3HTML%</td>
</tr>
</table>
Related
Problem: Currently I have problem aligning the PDF that I am creating as it is different with normal CSS that I know.
Problem:
What I need it to be solve:
Make it align, for the image I provided, I wanted "No.SAG" below "Old"
This is the code:
<table class="unstyledTable">
<thead>
<tr>
<th>Name:</th>
<th>Test Data</th>
<th></th>
<th>Number card IC</th>
<th></th>
<th></th>
</tr>
</thead>
<tfoot>
<tr>
<td>Name Agent::</td>
<td>TomHansom </td>
<td></td>
<td>New:</td>
<td>foot5</td>
<td></td>
</tr>
</tfoot>
<tbody>
<tr>
<td>Address:</td>
<td>werwrwrwwwwwwwwwwwwww wwwwwwwwwwwwwwwwwwww</td>
<td></td>
<td>Old:</td>
<td>cell5_1</td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td>No.SAG:</td>
<td>cell5_2</td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td>Number.Siri:</td>
<td>cell5_3</td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
Might be easier to put both in columns as tables in a parent table. Check out my code below to see if this is what you were after.
<table class="unstyledTable">
<tbody>
<tr>
<td valign="top"><table>
<tbody>
<tr class="unstyledTable">
<th>Name:</th>
<th>Test Data</th>
</tr>
<tr class="unstyledTable">
<td>Address:</td>
<td>werwrwrwwwwwwwwwwwwww wwwwwwwwwwwwwwwwwwww</td>
</tr>
<tr class="unstyledTable">
<td></td>
<td></td>
</tr>
<tr class="unstyledTable">
<td></td>
<td></td>
</tr>
<tr class="unstyledTable">
<td></td>
<td></td>
</tr>
<tr class="unstyledTable">
<td>Name Agent::</td>
<td>TomHansom </td>
</tr>
</tbody>
</table></td>
<td valign="top"><table>
<tbody>
<tr class="unstyledTable">
<th>Number card IC</th>
<th></th>
</tr>
<tr class="unstyledTable">
<td>Old:</td>
<td>cell5_1</td>
</tr>
<tr class="unstyledTable">
<td>No.SAG:</td>
<td>cell5_2</td>
</tr>
<tr class="unstyledTable">
<td>Number.Siri:</td>
<td>cell5_3</td>
</tr>
<tr class="unstyledTable">
<td></td>
<td></td>
</tr>
<tr class="unstyledTable">
<td>New:</td>
<td>foot5</td>
</tr>
</tbody>
</table></td>
</tr>
</tbody>
</table>
I am trying to display the array data into HTML table but table design or structure should be untouched irrespective of number of elements in array.
I tried some of logic like looping, but table structure changes.I don't want that.
Here is my code:
<?php
$goods=["ABC","XYZ","PQR","DEF"];
$qty=[12345,25120,14521,12541];
$rate=[12.00,13.02,15.00,14.00];
?>
<table>
<tr>
<th>Sr No.</th>
<th>Goods Description</th>
<th>Total Quantity(pcs)</th>
<th>Rate per unit(Rs.)</th>
<th colspan="3">Amount</th>
</tr>
<?php
for($i=0;$i<count($goods);$i++) {
?>
<tr>
<td><?php echo $goods[$i];?></td>
<td><?php echo $qty[$i];?></td>
<td><?php echo $rate[$i];?></td>
</tr>
<?php } ?>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td>Total Value</td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td>Frieght</td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td>Total Taxable Value</td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td>Tax</td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td>tax</td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td>tax</td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td>Total Tax Amount</td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td>Grand Total Tax Amount</td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td>ABC</td>
<td></td>
<td></td>
</tr>
</table>
Expected Output:
Expected_output
I think this is what you need. You had not included the words in the loop.
It was insanely hard to write this code on the phone so there may be something left out.
$goods=["ABC","XYZ","PQR","DEF"];
$qty=[12345,25120,14521,12541];
$rate=[12.00,13.02,15.00,14.00];
$words=["Total Value", "Frieght", "Total Taxable Value", "Tax", "Tax", "Tax", "Total Tax Amount"];
?>
<table>
<tr>
<th>Sr No.</th>
<th>Goods Description</th>
<th>Total Quantity(pcs)</th>
<th>Rate per unit(Rs.)</th>
<th colspan="3">Amount</th>
</tr>
<?php
for ($i=0;$i<count($words);$i++) {
?>
<tr>
<td><?php echo $i+1 . "."; ?></td>
<td><?php if(isset($goods[$i])) echo $goods[$i];?></td>
<td><?php if(isset($qty[$i])) echo $qty[$i];?></td>
<td><?php if(isset($rate[$i])) echo $rate[$i];?></td>
<td><?php echo $words[$i];?></td>
</tr>
<?php } ?>
</table>
https://3v4l.org/f1BnW.
Edit forgot number on first column.
I'm trying to create a pdf out of an html table which is created through php.
I use php version 5.4.7 and mdpf version 5.7.3.
This code does not work:
<?php
include('../../mpdf/mpdf.php');
$mpdf=new mPDF('utf-8', 'A4-L');
$test2 = "<table class='timon' border='1'>
<thead>
<tr>
<th></th>
<th>Montag</th>
<th>Dienstag</th>
<th>Mittwoch</th>
<th>Donnerstag</th>
<th>Freitag</th>
<th>Avg. Tag</th>
</tr>
</thead>
<tbody>
<tr>
<td>Morgen (0.3) </td>
<td><s>test user 0.36</s><br /></td>
<td></td>
<td><s>test user 0.26</s><br /></td>
<td></td>
<td></td>
<td> </td>
</tr>
<tr>
<td>Mittag (0.5) </td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td> </td>
</tr>
<tr>
<td>Nachmittag (0.5) </td>
<td><s>test user 0.16</s><br /></td>
<td></td>
<td></td>
<td></td>
<td><s>test user 0.46</s><br /></td>
<td> </td>
</tr>
<tr>
<td>Ganzer Tag (1) </td>
<td></td>
<td></td>
<td><s>test user 1.2</s><br /></td>
<td></td>
<td></td>
<td> </td>
</tr>
<tr>
<td>Total Auslastung</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td>Total Gruppe</td>
<td>7.5</td>
<td>7.5</td>
<td>7.5</td>
<td>7.5</td>
<td>7.5</td>
<td>7.5</td>
</tr><tr>
<td>Freie Plätze</td>
<td style='background-color:#c6efce;'>7.5</td>
<td style='background-color:#c6efce;'>7.5</td>
<td style='background-color:#c6efce;'>7.5</td>
<td style='background-color:#c6efce;'>7.5</td>
<td style='background-color:#c6efce;'>7.5</td>
<td style='background-color:#c6efce;'>7.5</td>
</tr>
</tbody>
</table>";
$mpdf->WriteHTML($test2,2);
$filename = "test.pdf";
$mpdf->Output($filename,'I');
exit;
?>
If I remove just one of the < s> tags, the PDF will be created fine. Eg.:
<td><s>test user 0.36</s><br /></td>
<td>test user 0.36<br /></td>
it also have problems with the < b> and < u> tag.
Any ideas?
You must close the <s> tag. mPDF is very strict with opening and closing tags. And not all of your opening tags are closed.
f.i.
<td><s>test user 0.36<s><br /></td>
Is not closed properly.
I found the mistake. I had an additional php include and this php had an body and html tag in it. I just removed it and now it works fine. BR
I am trying to create a html table showing results from php sql query. it is a result page of students php code is as under
$r1=$_GET["r"];
$con=mysqli_connect(localhost,chumspai_tlss,Tls121,chumspai_tlsResult);
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM nursery_blue_ WHERE sr_='$r1'");
while($row = mysqli_fetch_array($result))
{
html code is
<pre>
<form name="frmResult" id="frmResult" action="" method="post" onsubmit="return checkEmpty();">
<table width="80%" cellpadding="5" cellspacing="5" border="0">
<tr>
<td class="heading noborder">Enter Your Roll Number:</td>
<td class="noborder"><input type="text" id="r" name="r" value="" /></td>
</tr>
<tr>
<!--
<td class="heading noborder">Enter Your Name:</td>
<td class="noborder"><input type="text" id="name" name="name" value="" /></td>
</tr>
<tr>
<td class="heading noborder">Search by</td>
<td class="noborder"><input type="radio" id="option" name="option" value="rno" checked="checked" />
Roll No
<input type="radio" id="option" name="option" value="name" />
Name </td>
</tr>
-->
<tr>
<td class="noborder"> </td>
<td class="noborder"><input type="submit" name="submit" value="Search" />
<input type="reset" name="reset" value="Clear" />
</td>
</tr>
<!--<tr>
<td colspan="2"> <embed src="images/wait.swf"></embed></td>
</tr> -->
</table>
</form>
<div style="border:1px solid #000000;">
<table width="100%" cellpadding="10" cellspacing="0" border="0">
<tr>
<td class="heading grey" width="30%">RNO</td>
<td><?php
Print $row['sr_'];
?>
</td>
</tr>
<tr>
<td class="heading grey">NAME</td>
<td class="shade"></td>
</tr>
<tr>
<td class="heading grey">FATHER</td>
<td></td>
</tr>
<tr>
<td class="heading grey">regno</td>
<td></td>
</tr>
</table>
<table width="100%" cellpadding="10" cellspacing="0" border="0">
<tr class="grey">
<td rowspan="2" class="heading">Sr.no </td>
<td rowspan="2" class="heading">Name of subject </td>
<td rowspan="2" class="heading">Maximum Marks</td>
<td colspan="7" class="heading">detail of marks Obtained</td>
<tr class="grey">
<td class="heading">PART ONE</td>
<td class="heading">Total</td>
</tr>
<tr>
<td>1</td>
<td>Urdu</td>
<td></td>
<td> </td>
<td></td>
</tr>
<tr class="shade">
<td>2</td>
<td>English</td>
<td></td>
<td> </td>
<td></td>
</tr>
<tr>
<td>3</td>
<td>Islamyat</td>
<td></td>
<td> </td>
<td></td>
</tr>
<tr class="shade">
<td>4</td>
<td>pakstudies</td>
<td></td>
<td> </td>
<td></td>
</tr>
<tr class="shade">
<td>6</td>
<td></td>
<td></td>
<td></td>
<td>0</td>
</tr>
<tr>
<td>7</td>
<td></td>
<td></td>
<td></td>
<td>0</td>
</tr>
<tr class="shade">
<td>8</td>
<td></td>
<td></td>
<td></td>
<td>0</td>
</tr>
<tr class="shade">
<td>9</td>
<td></td>
<td></td>
<td></td>
<td>0</td>
</tr>
<tr class="grey">
<td colspan="2" class="heading">TOTAL</td>
<td class="heading">1100</td>
<td colspan="4" class="heading"></td>
</tr>
<tr class="grey">
<td colspan="3" class="heading">NOTIFICATION</td>
<td class="heading"></td>
<td class="heading"></td>
<td colspan="2" class="heading"></td>
</tr>
<tr>
<td colspan="7">(i) This provisional result intimation is issued as a notice only. Errors and omissions are excepted.</td>
</tr>
</table>
</pre>
please help me how to embed this php query with this html table and html form also.
you are not so far.
The variable $row is an array containing your data. Try this to see it's structure in your while call:
print_r($row);
Using this command you will see the name of each item of your array. Note it somewhere. Then you can do something like this:
...<td><?php echo $row['desired_column_name']; ?></td>...
If you receive data from your mysql query, this should do the trick.
Hope it helps,
Paul
Try This :
$result = mysql_query("select * from emp");
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td id=SrNo$cnt >".$row['eno']."</td>";
echo "<td id=ItemId$cnt >".$row['eId']."</td>";
echo "<td>". "<button name='Update' id='update' onclick='show(".$cnt.")'>UPDATE</button>"."</td>";
echo "<td>". "<button name='Report' id='show' onclick='Report(".$row['SrNo'].")'>REPORT</button>"."</td>";
echo "</tr>";
echo "<div id=show$cnt>";
echo "</div>";
$cnt++;
}
I have a report to be exported in xls format. The report was exported successfully in xls format but gridlines never show up even I have adjusted some options in the ms excel by checking the view gridline checkbox but gridlines still show nothing. I have suspected if maybe there is something wrong with my php export code. can you please help me with this? Here is my code.
xls export code
<?php
$file="report.xls";
$export ='<center><h1 class="lead">CITY Chamber</h1><img src= "base_url(images/agri_logo.jpg)" width="130px" height="130px"></center>
<div id="page-wrapper">
<table class="table table-bordered table-hover table-striped tablesorter">
<tr>
<td>First Name: </td>
<td>'.$report_rows[0]->fname.'</td>
</tr>
<tr>
<td>Last Name: </td>
<td>'. $report_rows[0]->lname.'</td>
</tr>
<tr>
<td>Gender: </td>
<td>'.$report_rows[0]->gender.'</td>
</tr>
<tr>
<td>Contact Number: </td>
<td>'.$report_rows[0]->contact.'</td>
</tr>
</table>
<table class="table table-bordered table-hover table-striped tablesorter">
<div class="table-responsive">
<table class="table table-bordered table-hover table-striped tablesorter">
<thead>
<tr>
<td colspan="2"><strong>Key Result Areas (KRA) / Program / Projects / Activities</strong></td>
<td><strong>Target</strong></td>
<td colspan="2" style="text-align:center;"><center> '.$report_rows[0]->prev_month_year.'</center></td>
<td colspan="2" ><center> '.$report_rows[0]->pres_month_year.' </center></td>
<td><strong>Total</strong></td>
</tr>
</thead>
<form id="at_report_form" method="post">
<tbody>
<tr>
<td></td>
<td></td>
<td></td>
<td> '.$dropdown_brgy1[$data_reports['prev_brgy1']].' </td>
<td> '.$dropdown_brgy1[$data_reports['prev_brgy2']].' </td>
<td> '.$dropdown_brgy1[$data_reports['pres_brgy1']].' </td>
<td> '.$dropdown_brgy1[$data_reports['pres_brgy2']].' </td>
<td></td>
</tr>
<tr>
<td>1. KRA No. 1: Production Enhancement & Environment </td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td> Protection Agenda (PEEPA)</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>1.1 Support to Crop Production Enhancement </td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>1.1.1 Rice Production Self Sufficiency Program</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><span style="margin-left:30px;">a. Provision of certified seeds</span></td>
<td>no. of bags</td>
<td>per AT</td>
<td><center> '.$data_reports['a'].'</center></td>
<td> <center>'.$data_reports['b'].'</center></td>
<td><center> '.$data_reports['c'].'</center></td>
<td> <center>'.$data_reports['d'].'</center></td>
<td><center> '.$data_reports['total_1'].'</center></td>
</tr>
<tr>
<td></td>
<td>no. of farmers</td>
<td></td>
<td><center>'.$data_reports['e'].'</center></td>
<td><center>'.$data_reports['f'].'</center></td>
<td><center>'.$data_reports['g'].'</center></td>
<td><center>'.$data_reports['h'].'</center></td>
<td><center>'.$data_reports['total_2'].'</center></td>
</tr>
<tr>
<td style="text-align:center;">Rehab Seeds</td>
<td>no. of bags</td>
<td>per AT</td>
<td><center>'.$data_reports['i'].'</center></td>
<td><center>'.$data_reports['j'].'</center></td>
<td><center>'.$data_reports['k'].'</center></td>
<td><center>'.$data_reports['l'].'</center></td>
<td><center>'.$data_reports['total_3'].'</center></td>
</tr>
<tr>
<td></td>
<td>no. of farmers</td>
<td></td>
<td><center>'.$data_reports['m'].'</center></td>
<td><center>'.$data_reports['n'].'</center></td>
<td><center>'.$data_reports['o'].'</center></td>
<td><center>'.$data_reports['p'].'</center></td>
<td><center>'.$data_reports['total_4'].'</center></td>
</tr>
<tr>
<td><span style="margin-left:30px;">b. Provision of pest control assistance</span></td>
<td>no. of kgs (ratoxin)</td>
<td>per AT</td>
<td><center>'.$data_reports['q'].'</center></td>
<td><center>'.$data_reports['r'].'</center></td>
<td><center>'.$data_reports['s'].'</center></td>
<td><center>'.$data_reports['t'].'</center></td>
<td><center>'.$data_reports['total_5'].'</center></td>
</tr>
</tbody>
</form>
</table></div></div>';
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=$file");
echo $export; ?>
Output (Gridlines never show up even I have checked the gridlines view checkbox):
optput ur html using table tags
use
<table border=1>