|
|
|
browser import export excel php ไมได้ครับ......... |
|
|
|
|
|
|
|
Code (PHP)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
<!-- Bootstrap -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
</head>
<body >
<form action="index.php" method="post" enctype="multipart/form-data">
<input type="file" name="filUpload" class="form-control-static">
<input type="text" name="age" class="form-control-static">
<button type="submit" class="btn btn-success" name="impirt"> Import </button>
</form>
</body>
</html>
<?php
$connect = mysqli_connect("localhost", "root", "", "convert_excel_db");
include ("PHPExcel/IOFactory.php");
if(move_uploaded_file($_FILES["filUpload"]["tmp_name"],"upload/".$_FILES["filUpload"]["name"]))
{
$filUpload=$_POST(['filUpload']);
echo $filUpload;
$html="<table border='1'>";
$objPHPExcel = PHPExcel_IOFactory::load($filUpload);
foreach ($objPHPExcel->getWorksheetIterator() as $worksheet)
{
$highestRow = $worksheet->getHighestRow();
for ($row=2; $row<=$highestRow; $row++)
{
$html.="<tr>";
$name = mysqli_real_escape_string($connect, $worksheet->getCellByColumnAndRow(0, $row)->getValue());
$email = mysqli_real_escape_string($connect, $worksheet->getCellByColumnAndRow(1, $row)->getValue());
$sql = "INSERT INTO tbl_excel(excel_name, excel_email) VALUES ('".$name."', '".$email."')";
mysqli_query($connect, $sql);
$html.= '<td>'.$name.'</td>';
$html .= '<td>'.$email.'</td>';
$html .= "</tr>";
}
}
echo "Copy/Upload Complete";
}
$html .= '</table>';
echo $html;
echo '<br />Data Inserted';
?>
ขอบคุณครับ
Tag : PHP, MySQL
|
|
|
|
|
|
Date :
2016-10-04 21:59:55 |
By :
โต้ง |
View :
1047 |
Reply :
7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
มี Error อะไรไหม๊ครับ
|
|
|
|
|
Date :
2016-10-05 10:15:32 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ิbrower file import ไม่เข้าครับ
แต่ใช่้ $objPHPExcel = PHPExcel_IOFactory::load('upload/exm.xlsx');
ได้ปกติ
$filUpload=$_POST(['filUpload']);
ไม่ได้ครับ
|
|
|
|
|
Date :
2016-10-05 14:52:08 |
By :
โต้ง |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
การส่งค่าจาก input type text file จะรับเป็น $filUpload=$_POST(['filUpload']); ไม่ได้ มันก็ถูกต้องแล้วนะครับ
|
|
|
|
|
Date :
2016-10-05 15:23:54 |
By :
apisitp |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
$html="<table border='1'>";
$objPHPExcel = PHPExcel_IOFactory::load('upload/example.xlsx'); path ได้ครับ แต่พอใส่ brower file html ไม่ได้ครับ
echo $filUpload;
foreach ($objPHPExcel->getWorksheetIterator() as $worksheet)
{
$highestRow = $worksheet->getHighestRow();
for ($row=2; $row<=$highestRow; $row++)
{
$html.="<tr>";
$name = mysqli_real_escape_string($connect, $worksheet->getCellByColumnAndRow(0, $row)->getValue());
$email = mysqli_real_escape_string($connect, $worksheet->getCellByColumnAndRow(1, $row)->getValue());
$sql = "INSERT INTO tbl_excel(excel_name, excel_email) VALUES ('".$name."', '".$email."')";
mysqli_query($connect, $sql);
$html.= '<td>'.$name.'</td>';
$html .= '<td>'.$email.'</td>';
$html .= "</tr>";
}
}
$html .= '</table>';
echo $html;
echo '<br />Data Inserted';
|
|
|
|
|
Date :
2016-10-06 09:40:42 |
By :
โต้ง |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ถ้า type = "file" เรียกใช้ตัวแปรข้างล่าง ด้วย POST ไม่ได้ครับ
$filUpload=$_POST(['filUpload']);
ต้องเรียกใช้เหมือนบันทัดที่ 27 ของ จขกท ครับ
|
|
|
|
|
Date :
2016-10-06 10:03:24 |
By :
Chaidhanan |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ทำได้แล้ว ขอบคุณพี่่ๆๆมากครับ
Code (PHP)
include("connect_db.php");
include ("PHPExcel/IOFactory.php");
if(move_uploaded_file($_FILES["filUpload"]["tmp_name"],"upload/".$_FILES["filUpload"]["name"]))
{
$filUpload="upload/".$_FILES["filUpload"]["name"];
$objPHPExcel = PHPExcel_IOFactory::load($filUpload);
$last_date=$_POST['last_date'];
$author=$_POST['author'];
|
|
|
|
|
Date :
2016-10-10 17:38:29 |
By :
โต้ง |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|