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 | |||||
2024-12-14 (2 days ago) | Not enough user ratings | Total: 29 This week: 29 | All time: 11,170 This week: 1 |
Version | License | PHP version | Categories | |||
exceltohtml 1.0.0 | 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 more common Conditional Formatting styles. 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.1.
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 timothy.edwards1@btinternet.com
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)
$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 - Includes headers and footers, but no row or column references or sheet name. (Default)
$text = $rt->readDocument('FILENAME','AOS'); 'Spreadsheet' mode - Includes row and column references and the sheet name but no headers/footers.
None yet
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.