PHP code example of elton182 / spreadsheet

1. Go to this page and download the library: Download elton182/spreadsheet 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/ */

    

elton182 / spreadsheet example snippets


		namespace App\Controller;

		use App\Controller\AppController;
		use elton182\spreadsheet\SpreadsheetReader;

		class ExcelController extends AppController
		{

			
			public function index(){
			
				if($this->request->is('post')){
			
					$arquivo = $this->request->data['uploadfile'][0]['tmp_name'];
					$nome = $this->request->data['uploadfile'][0]['name'];

					$Reader = new SpreadsheetReader($arquivo,$nome);
				    foreach ($Reader as $Row)
				    {
				        print_r($Row);
				    }

				}


			}
		}
	

		// If you need to parse XLS files, include php-excel-reader
		heetReader('example.xlsx');
		foreach ($Reader as $Row)
		{
			print_r($Row);
		}
	

		$Reader = new SpreadsheetReader('example.xlsx');
		$Sheets = $Reader -> Sheets();

		foreach ($Sheets as $Index => $Name)
		{
			echo 'Sheet #'.$Index.': '.$Name;

			$Reader -> ChangeSheet($Index);

			foreach ($Reader as $Row)
			{
				print_r($Row);
			}
		}