Reputation: 3
I recently download PHPExcel and am liking what I have seen so far. One of my goals is to have excel files that are being worked on automatically uploaded onto our database and displayed on a webpage
I found a great link (https://www.youtube.com/watch?v=ZwRPKvElM9U) on youtube that explains this but when i try to grab an excel file that is not on my local machine it doesn't load properly.
I have tested file_exists and the file can be seen normally through PHP
`"//test-fps/Sales/test1.xlsx"`
<?php
$connect = mysqli_connect("localhost", "root", "pass","server");
include ("PHPExcel/IOFactory.php");
$html = "<table border='1'>";
$objPHPExcel = PHPExcel_IOFactory::load("//test-fps/Sales/test1.xlsx");
foreach ($objPHPExcel->getWorksheetIterator() as $worksheet)
{
$highestRow = $worksheet->getHighestRow();
for ($row=2; $row<=$highestRow; $row++)
{
$html.="<tr>";
$ticketnumber = mysqli_real_escape_string($connect,$worksheet->getCellByColumnAndRow(0,$row)->getValue());
$status = mysqli_real_escape_string($connect,$worksheet->getCellByColumnAndRow(1,$row)->getValue());
$sql = "INSERT INTO tbl_excel(ticketnumber, status) VALUES ('".$ticketnumber."', '".$status."')";
mysqli_query($connect, $sql);
$html.='<td>' .$ticketnumber . '</td>';
$html.= '<td>' .$status. '</td>';
$html.= "</tr>";
}
}
$html .= "</table>";
echo $html;
echo '<br />Data Inserted';
?>
Upvotes: 0
Views: 199
Reputation: 212412
The file must exist on your local machine. You cannot load a remote file directly into PHPExcel. This is because parsing Excel files requires the ability to use fseek()
to move the filepointer around within the file that it is loading; and this isn't an option that is supported in remote file access, only in local file access.
Upvotes: 1