Skip to content

Instantly share code, notes, and snippets.

@theredstapler
Last active November 20, 2020 16:42
Show Gist options
  • Save theredstapler/b5c835321080e69df9947f5de5325d51 to your computer and use it in GitHub Desktop.
Save theredstapler/b5c835321080e69df9947f5de5325d51 to your computer and use it in GitHub Desktop.
<!doctype>
<html>
<head>
</head>
<body>
<?php
require_once "Classes/PHPExcel.php";
$tmpfname = "test.xlsx";
$excelReader = PHPExcel_IOFactory::createReaderForFile($tmpfname);
$excelObj = $excelReader->load($tmpfname);
$worksheet = $excelObj->getSheet(0);
$lastRow = $worksheet->getHighestRow();
echo "<table>";
for ($row = 1; $row <= $lastRow; $row++) {
echo "<tr><td>";
echo $worksheet->getCell('A'.$row)->getValue();
echo "</td><td>";
echo $worksheet->getCell('B'.$row)->getValue();
echo "</td><tr>";
}
echo "</table>";
?>
</body>
</html>
@pipopinpollo
Copy link

pipopinpollo commented Jul 1, 2019

require_once( . 'phpExcel/PHPExcel.php');
function load_and_save_excel($data){

	//var for open excel php
	$tmpfname = 'temp/'.$data['archivo']['name'];//file path
	$excelReader = PHPExcel_IOFactory::createReaderForFile($tmpfname);
	$excelObj = $excelReader->load($tmpfname);
	$worksheet = $excelObj->getSheet(0);//here you get the sheet wiht a method you can change the 0 for i and use all sheet you 
            //want
	$lastRow = $worksheet->getHighestRow();//here you get the last row of the selected sheet

	
    $list=[]; //list

   
                        // in this case the column is hard code, but you can use  a array for load the letters and use a double for $i $j
                         //


	for ($row = 1; $row <= $lastRow; $row++) {
        $position = $row-1;
        $list[$position][0]= $worksheet->getCell('A'.$row)->getValue(); //   column A row 0
        $list[$position][1]= $worksheet->getCell('B'.$row)->getValue(); // column B row 0  
        $list[$postion][2]= $worksheet->getCell('C'.$row)->getValue(); //column C row 0
        $list[$position][3]= $worksheet->getCell('D'.$row)->getValue(); //column D row 0 etc
     
    		 
    }
    
    return $list;

}

@dewdrops-of-winter
Copy link

Does it capture real-time live data feed from Excel and populate into PHP?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment