Hire a web Developer and Designer to upgrade and boost your online presence with cutting edge Technologies

Saturday, October 8, 2022

Create excel file in PHP without using any libraries

 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

No comments:

Post a Comment