我想搜索一個字符串,將它與數組進行比較,並輸出 單元格及其對應的行。帶搜索按鈕的PHPExcel
在此先感謝!
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<form action="index.php" class="contact_form" method = "post">
<p>Please enter your name:</p>
<input name="fname" id="fname" type="fname"/><br/>
<br>
<br>
<input type="submit" name="submit" class="submit" value="Submit" />
</form>
<?php
/** Include path **/
set_include_path(get_include_path() . PATH_SEPARATOR . 'Classes/');
/** PHPExcel_IOFactory */
include 'PHPExcel/IOFactory.php';
$inputFileName = './check.xlsx'; // File to read
//echo 'Loading file ',pathinfo($inputFileName,PATHINFO_BASENAME),' using IOFactory to identify the format<br />';
try {
$objPHPExcel = PHPExcel_IOFactory::load($inputFileName);
} catch(Exception $e) {
die('Error loading file "'.pathinfo($inputFileName,PATHINFO_BASENAME).'": '.$e->getMessage());
}
echo '<hr />';
echo "<pre>";
$data = array();
$worksheet = $objPHPExcel->getActiveSheet();
foreach ($worksheet->getRowIterator() as $row) {
$cellIterator = $row->getCellIterator();
$cellIterator->setIterateOnlyExistingCells(false);
foreach ($cellIterator as $cell_raw) {
$data[$cell_raw->getRow()][$cell_raw->getColumn()] = $cell_raw->getValue();
$c =$_POST['fname'];
if ($c === $data){
echo 'test';
}
}
}
var_dump($data);
/* foreach($sheetData as $rec) {
print_r($rec);
}
*/
?>
<body>
</html>
我想搜索,它比較所述陣列和輸出 細胞和其對應的行的字符串。
請說爲什麼你的答案是對問題的解決方案。 – Koopakiller