Recommend this page to a friend! |
Download |
Info | Example | Files | Install with Composer | Download | Reputation | Support forum | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2025-01-14 (4 days ago) | Not enough user ratings | Total: 66 This week: 23 | All time: 10,372 This week: 2 |
Version | License | PHP version | Categories | |||
exceltohtml 1.0.3 | GNU General Publi... | 5 | HTML, PHP 5, Files and Folders, Parsers, D... |
Description | Author | |
This class can convert an Excel spreadsheet to HTML. |
A test demonstration page at https://phpscripts.meccanoindex.co.uk/ where you can try this script out with one of your own Excel documents.
<!DOCTYPE html>
|
This php script will convert an Excel .XLSX file to html and display the resultant code (including images) in a web page. It will recognise nearly all the formatting, images etc. in the original Excel XLSX document including the most Conditional Formatting styles except Icon Sets and those based on formulas. At present it doesn't support graphs and charts.
NOTE:- Needs at least php 5 and will run on up to (at least) php 8.2.
NOTE:- It will not read the older 'XLS' Excel format. In this case it will give an error message saying that it is a 'non zip file'.
I have a website featuring all my php scripts where you can also test this script with one of your own Excel documents - https://phpscripts.meccanoindex.co.uk. You can also contact me through my website.
FEATURES
If anyone finds any problems or has sugestions for enhancements, please contact me on [email protected]
require_once('excelphp.php');
$rt = new ExcelPHP(false);
$text = $rt->readDocument('FILENAME','');
echo $text;
require_once('excelphp.php');
Will display the various zipped XML files in the XLSX file which are used by the class for the document being converted and will also display the resultant HTML.
$rt = new ExcelPHP(true);
$rt = new ExcelPHP(false); or $rt = new ExcelPHP();
You can alter the encoding of the resultant HTML - eg. 'ISO-8859-1', 'windows-1252', etc. Although note that many special chacters and symbols may not then display correctly so the default should be used whenever practical.
$rt = new ExcelPHP(false, 'ISO-8859-1');
Will change the directory used for any images in the document.
$rt = new ExcelPHP(false, null, 'dir_name');
See below for various options
$text = $rt->readDocument('FILENAME','');
echo $text;
$myfile = fopen("xlfile.php", "w") or die("Unable to open file!");
fwrite($myfile, $text)
Default is to show all sheets. However you can also select an individual sheet. This is selected by the first character in the last parameter of readDocument(), i.e.:-
$text = $rt->readDocument('FILENAME','A'); Display all sheets in the Excel spreadsheet. (Default)
$text = $rt->readDocument('FILENAME','2'); Sheet two is shown selected for display here.
Default is to make the Column Widths and Row Heights approx the same as the original spreadsheet. This is selected by the second character in the last parameter of readDocument(), i.e.:-
$text = $rt->readDocument('FILENAME','AO'); The Column Widths and Row Heights will be approx the same as the original spreadsheet. (Default, so option character not necessarily needed)
$text = $rt->readDocument('FILENAME','AA'); 'Auto' mode, it will let the browser choose the Column Widths and Row Heights.
Default is to make display similar to a printed spreadsheet. This is selected by the third character in the last parameter of readDocument(), i.e.:-
$text = $rt->readDocument('FILENAME','AOP'); 'Print' mode - Displays the 'Print Area' (if set). Includes headers and footers, but no row or column references or sheet name. (Default, so option character not necessarily needed)
$text = $rt->readDocument('FILENAME','AOS'); 'Spreadsheet' mode - Includes row and column references and the sheet name but no headers/footers.
You can choose whether to have the gridlines or not. Default is to have them.
$text = $rt->readDocument('FILENAME','AOPG'); 'Display Gridlines' mode. Will display gridlines (assuming that gridlines are shown in the Excel document. (Default, so option character not necessarily needed)
$text = $rt->readDocument('FILENAME','AOPN'); 'No Gridlines' mode. Will not display gridlines
Version 1.0.3 - A bug is cleared that prevented some images from being shown. Also it now follows the original Excel spreadsheet as to whether gridlines are shown or not. There is also a new option to not show gridlines when they would otherwise be shown. When in the 'Print' display mode, it will now just show the Excel defined 'Print Area' - assuming it is set. Also in some environments a lot of warning messages were displayed. These have now been cleared.
Version 1.0.2 - Removed a depreciated aspect of strpos.
Version 1.0.1 - It provides the following enhancements - It will now recognise more number formatting. It will now replicate the following Conditional Formatting (except formula based ones) - Data Bar, Colour Scale, Top N(N%), Bottom N(N%), Above/below average and 1,2,3 Standard Deviations Away. It now gives better support/replication for currency units - particularly trailing ones. In accounting formatting a '0' amount will be now be displayed as '-' as per Excel. Also a number of bugs have been cleared.
Files (4) |
File | Role | Description |
---|---|---|
excelphp.php | Class | ExcelPHP Class source |
LICENSE | Lic. | License text |
README.md | Doc. | Documentation |
test.php | Example | Example script |
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 |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.