Press enter to see results or esc to cancel.


Create excel file in PHP without using any libraries


In this video I have shown you how you can create excel file in PHP without using any libraries.
Just add 2 lines of code mentioned below in your php page. The page will create an excel file and download it.

header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=chillyfacts.com.xls");

The example page I shown in the video is,

index.php

<?php
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=chillyfacts.com.xls");
echo 'jinu';
 ?>
 <br>
 <table style="width:100%" border='1'>
  <tr>
    <th>Firstname</th>
    <th>Lastname</th> 
    <th>Age</th>
  </tr>
  <tr>
    <td>Jill</td>
    <td>Smith</td> 
    <td>50</td>
  </tr>
  <tr>
    <td>Eve</td>
    <td>Jackson</td> 
    <td>94</td>
  </tr>
</table>

On running the above code on server. It will create the excel file as shown below.



Tags

Comments

Comments are disabled for this post