PHP code example of shuchkin / simplexls

1. Go to this page and download the library: Download shuchkin/simplexls library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

shuchkin / simplexls example snippets


if ( $xls = SimpleXLS::parseFile('book.xls') ) {
	print_r( $xls->rows() );
	// echo $xls->toHTML();	
} else {
	echo SimpleXLS::parseError();
}

// open
SimpleXLS::parse( $filename, $is_data = false, $debug = false ): SimpleXLS (or false)
SimpleXLS::parseFile( $filename, $debug = false ): SimpleXLS (or false)
SimpleXLS::parseData( $data, $debug = false ): SimpleXLS (or false)
SimpleXLS:parseError(): string
// simple
$xls->rows($worksheetIndex = 0, $limit = 0): array
$xls->readRows($worksheetIndex = 0, $limit = 0): Generator - helps read huge xlsx
$xls->toHTML($worksheetIndex = 0, $limit = 0): string
// extended
$xls->rowsEx($worksheetIndex = 0, $limit = 0): array, values + meta
// meta
$xls->sheetNames():array
$xls->sheetName($worksheetIndex):string

echo SimpleXLS::parse('book.xls')->toHTML();

if ( $xls = SimpleXLS::parse('book.xls') ) {
	echo '<table border="1" cellpadding="3" style="border-collapse: collapse">';
	foreach( $xls->rows() as $r ) {
		echo '<tr><td>'.implode('</td><td>', $r ).'</td></tr>';
	}
	echo '</table>';
} else {
	echo SimpleXLS::parseError();
}

if ( $xls = SimpleXLS::parseFile('book.xls') ) {
  print_r( $xls->sheetNames() );
  print_r( $xls->sheetName( $xls->activeSheet ) );
}

if ( $xls = SimpleXLS::parseFile('book.xls') ) {
  print_r( $xls->boundsheets ); 
}

$xls = new SimpleXLS('books.xls');
if ($xls->success()) {
	print_r( $xls->rows() );
} else {
	echo 'xls error: '.$xls->error();
}

ini_set('error_reporting', E_ALL );
ini_set('display_errors', 1 );

//header('Content-Type: text/html; charset=utf-8');

$xls = SimpleXLSX::parse('books.xls', false, true );
print_r( $xls->rows() );
print_r( $xls->sheets );

$xls->rows( $sheetIndex, $limit = 0 )