PHP Classes

PHP HTML Excel: Convert HTML to Excel spreadsheets

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 65%Total: 2,211 All time: 1,768 This week: 49Up
Version License PHP version Categories
htmlexcel 1.0.2Custom (specified...5Tools
Description 

Author

This class can convert HTML to Excel spreadsheets.

It can take the HTML of a table rows and headers, as well optional CSS, and generates a file that can be opened as a spreadsheet in Microsoft Excel.

The class can serve the Excel file for download using the appropriate headers for making it open in Excel or equivalent server in the user machine.

This class is able to create Excel spreadsheets directly from HTML tables. It is possible to use CSS for styling.

Picture of Gustavo Alves
  Performance   Level  
Name: Gustavo Alves <contact>
Classes: 1 package by
Country: Brazil Brazil
Age: 36
All time rank: 138689 in Brazil Brazil
Week rank: 268 Up19 in Brazil Brazil Up

Recommendations

What is the best PHP export excel class?
Trying to export query to an Excel file

Documentation

HtmlExcel

Turn HTML tables into multi-sheet Excel files.

Example

require_once('HtmlExcel.php');

$css = "
.red {
	color: red;
}";

$numbers = '<table>
<tr>
	<td class="red">1</td>
	<td>2</td>
	<td>3</td>
</tr>
<tr>
	<td>4</td>
	<td class="red">5</td>
	<td>6</td>
</tr>
<tr>
	<td>7</td>
	<td>8</td>
	<td class="red">9</td>
</tr>
</table>';

$names = '<table>
  <tr>
    <th>First name</th>
    <th>Last name</th>
  </tr>
  <tr>
    <td>John</td>
    <td>Doe</td>
  </tr>
  <tr>
    <td>Jane</td>
    <td>Doe</td>
  </tr>
</table>';

$xls = new HtmlExcel();
$xls->setCss($css);
$xls->addSheet("Numbers", $numbers);
$xls->addSheet("Names", $names);
$xls->headers();
echo $xls->buildFile();

  Files folder image Files (3)  
File Role Description
Plain text file HtmlExcel.php Class Class source
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:2,211
This week:0
All time:1,768
This week:49Up
User Ratings User Comments (1)
 All time
Utility:93%StarStarStarStarStar
Consistency:93%StarStarStarStarStar
Documentation:93%StarStarStarStarStar
Examples:-
Tests:-
Videos:-
Overall:65%StarStarStarStar
Rank:613