Hi guys I have a excel sheet that I want to pull some info and publish it... it looks like
so far I have done putting them into option tab the company names like drop down menu.
I want to do the selected ones information like the one in the picture:
But I couldnt make it dynamic to make it appear.... can you give a clue about how to make it dynamic?( not asking about ajax... I am asking to show it from choosing from array and showing available one) here is code
<?php
set_include_path(implode(PATH_SEPARATOR, [
realpath(__DIR__ . '/Classes'), // assuming Classes is in the same directory as this script
get_include_path()
]));
require_once dirname(__FILE__) . '/Classes/PHPExcel/IOFactory.php';
require_once 'PHPExcel.php';
$file= "./uploads/".$_GET["filename"];
$inputFileName = ($file);
// Read your Excel workbook
try {
$inputFileType = PHPExcel_IOFactory::identify($inputFileName);
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load($inputFileName);
}
catch(Exception $e) {
die('Error loading file "'.pathinfo($inputFileName,PATHINFO_BASENAME).'": '.$e->getMessage());
}
// Get worksheet dimensions
$sheet = $objPHPExcel->getSheet(0);
$highestRow = $sheet->getHighestRow();
$highestColumn = $sheet->getHighestColumn();
/*
$total=array();
// Loop through each row of the worksheet in turn
for ($row = 1; $row <= $highestRow; $row++) {
// Read a row of data into an array
$rowData = $sheet->rangeToArray('A' . $row . ':' . $highestColumn . $row, NULL, TRUE, FALSE);
// echo "-----------------as rowData---------------";
// var_dump($rowData); // Insert row data array into your database of choice here
// echo "-----------------VAR_DUMP total!---------------";
array_push($total, $rowData);
// var_dump($total);
$myFlatArray = PHPExcel_Calculation_Functions::flattenArray($total);
echo "<br>";
echo "----------------- total as json encode---------------";
var_dump(json_encode($myFlatArray));
}
*/
$foundInCells = array();
$searchValue = 'Company';
$wscounter=0; //worksheet counter
foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) {
echo "<hr><p> Worksheet count: " . $wscounter . " name: " . $worksheet->getTitle() . "</p>";
///START Sirket isimlerini listele
$column = 'B';
$lastRow = $worksheet->getHighestRow();
echo '<p> Company name: <select id="my_select">';
for ($row = 1; $row <= $lastRow; $row++) {
if($worksheet->cellExists($column.$row))
{
echo "<option value='".$column.$row."'>". $worksheet->getCell($column.$row)->getValue() . "</option>";
}
}
echo "</select> </p>";
///END Sirket isimlerini listele
$rowCompanyInfoStart = 4;
$rowCompanyInfoEnd = 9;
$colCompanyInfoStart = 'C';
$colCompanyInfoEnd = 'L';
echo "<table border='1'>";
// echo " print row ";
// echo $_POST["getCell($column.$row)"];
for ($rowcount = $rowCompanyInfoStart; $rowcount <= $rowCompanyInfoEnd; $rowcount++) {
//$data = $objWorksheet->rangeToArray('A1:' . $maxCell['column'] . $maxCell['row']);
$rangeCoordinates = $colCompanyInfoStart . $rowcount . ':' . $colCompanyInfoEnd . $rowcount;
$rowData = $sheet->rangeToArray($rangeCoordinates, NULL, TRUE, FALSE);
//fazla bosluk olursa bunları aç ya da hucre bos mu kontrol et (cellExists ile)
//rowData = array_map('array_filter', $rowData);
//$rowData = array_filter($rowData);
echo "<tr>";
foreach($rowData[0] as $result) {
echo "<td>".$result." </td>";
}
echo "</tr>";
}
echo "</table>";
/* GB01 START
//try {
/// Y 0 değil 1 den basliyor dikkat
$rowcounter=1;
foreach ($worksheet->getRowIterator() as $row) {
echo "Worksheet " . $wscounter . " Row " . $rowcounter . "<br/>";
$cellIterator = $row->getCellIterator();
$cellIterator->setIterateOnlyExistingCells(true);
$cellcounter=0;
$hitcounter=0;
foreach ($cellIterator as $cell) {
echo "Worksheet " . $wscounter . " Row " . $rowcounter . " Cell " . $cellcounter . "<br/>";
if ($cell->getValue() == $searchValue) {
$hitcounter++;
echo "hitcounter" . $hitcounter . "<br/>";
$foundInCells[] = $worksheet->getTitle() . '!' . $cell->getCoordinate();
}
$cellcounter++;
}
$rowcounter++;
}
/*
}
// catch (Exception $exc) {
// echo "<div style='padding:5px; background-color:#fc8888'> Exception caught on Worksheet " . $wscounter . " Row " . $rowcounter . "<br/>" . $exc->getMessage() . "</div>";
// }
$wscounter++;
//GB01 END */
}
echo "-----found in cells----------------------------------------------------------------";
var_dump($foundInCells);
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Autocomplete - Default functionality</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script>
/* $(function() {
var availableTags = $.parseJSON('<?php echo json_encode($myFlatArray); ?>');
$( "#tags" ).autocomplete({
source: availableTags
});
}); */
function todo()
{
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("my_select").innerHTML=xmlhttp.responseText;
}
}
}
</script>
</head>
<body>
<br><br><br>
<div class="ui-widget">
<label for="tags">Tags: </label>
<input id="tags">
<br><br><br><br>
</div>
</body>
</html>
Here is my full solution! if you have any question please comment under this solution however it works pretty good!