|
|
|
แสดงรูปภาพจากไฟล์ Excel ด้วย PHPExcel ทำอย่างไรหรอคะ |
|
|
|
|
|
|
|
ไฟล์ EXCEL ที่นำมาแสดงที่มีรูปภาพด้วย
หน้าโปรแกรมที่ดึงข้อมูลมาอ่านได้แล้วแต่แสดงรูปภาพไม่ได้
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</head>
<body>
<form id="form1" name="form1" method="post" enctype="multipart/form-data">
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="2">
<br>
<tr>
<td align="right" valign='top'>เลือกไฟล์เพื่อทำการดึงข้อมูล</td>
<td colspan ="3" align="align" valign='top'>
<input type="file" name="dir_to_load" size="50" class="form-control-file" >
</td>
</tr>
<tr>
<td height="64" colspan="3" align="center">
<input name="SR" type="submit" class="btn btn-primary" id="SR" value="Preview" tabindex="10" />
</td>
</tr>
</table>
</form>
<script>
function ExportToExcel(type, fn, dl) {
var elt = document.getElementById('myTable');
var wb = XLSX.utils.table_to_book(elt, { sheet: "sheet1" });
return dl ?
XLSX.write(wb, { bookType: type, bookSST: true, type: 'base64' }) :
XLSX.writeFile(wb, fn || ('MySheetName.' + (type || 'xlsx')));
}
</script>
<?PHP
include ('PHPExcel.php');
include ('PHPExcel/IOFactory.php');
if(isset($_POST['SR']))
{
$file_name = $_FILES['dir_to_load']['name'];
if ($file_name != "")
{
global $objPHPExcel;
//==================== Read Excel ==================
$objPHPExcel = PHPExcel_IOFactory::load($_FILES['dir_to_load']['tmp_name']);
$objWorksheet = $objPHPExcel->setActiveSheetIndex(0);
$highestRow = $objWorksheet->getHighestRow();
$highestColumn = $objWorksheet->getHighestColumn();
$gdImage = imagecreatefromjpeg('img_for_test.jpg');
$pic= "<img src='img_for_test.jpg'><br>";
$r = -1;
$namedDataArray = array();
$ctn=1;
$i=0;
echo "<div class='' style='background-color: #A4DEFF; '>";
echo "<br>";
echo "<TABLE id='myTable' border='2' style='background-color: white;' class='table'>";
echo "<tr>";
for ($row = 1; $row <= $highestRow; ++$row)
{
if ($i++ % 3 == 0) echo "<tr>";
echo "<td>" ;
echo "<b>".$ctn."</b><br>";
echo $pic;
for ($column = 'A'; $column <= $highestColumn; $column++)
{
echo $objPHPExcel->getActiveSheet()->getCell($column.$row)->getValue()."<br>";
}
$ctn++;
echo "</td>" ;
}
$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
$objWriter->save(str_replace('.php', '.xlsx', "test002.xlsx"));
$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
$objWriter->save(str_replace('.php', '.xlsx', "test001.xlsx"));
echo "</tr>"; echo "</table>";
echo "<a href='test001.xlsx' class='btn btn-primary'>EXPORT TO EXCEL 1</a> ";
echo "<a href='test002.xlsx' class='btn btn-primary'>EXPORT TO EXCEL 2</a> ";
echo "<br><br><br>";
echo "</div>";
echo "<br><br><br>";
}
}
?>
</html>
<p>
</body>
รบกวนช่วยด้วยค่ะ มือใหม่มากๆ
Tag : - - - -
|
|
|
|
|
|
Date :
2021-09-13 08:58:51 |
By :
watalkd |
View :
663 |
Reply :
0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|