|
 |
|
สอบถามหน่อยครับ จะทำยังไงให้ มัน read excel ออกมามีเลข 00 ที่อยู่ข้างหน้าออกมาด้วยอ่ะครับ |
|
 |
|
|
 |
 |
|
สอบถามหน่อยครับ จะทำยังไงให้ มัน read excel ออกมามีเลข 00 ออกมาด้วยอ่ะครับ (read ธรรมดาพอ print ออกใมา จาก 001 มันออกมา
เป็น 1)
รูปทางซ้ายคือตอนยังไม่คลิดที่คอลัมน์นะครับ จะมี 001
รูปทางขวาคือตอนคลิกที่คอลัมน์ จะเหลือแค่ 1

Code (PHP)
<?php
header('Content-Type: text/html; charset=utf-8');
if(isset($_FILES['file'])){
$type = substr($_FILES["file"]['name'], strripos($_FILES["file"]['name'],'.'), strlen($_FILES["file"]['name']));
$rnd = rand(0,99999);
$uniqueName = $rnd.$type;
move_uploaded_file($_FILES['file']['tmp_name'],$uniqueName);
require_once 'PHPExcel/Classes/PHPExcel.php';
/** PHPExcel_IOFactory - Reader */
include 'PHPExcel/Classes/PHPExcel/IOFactory.php';
$objPHPExcel = new PHPExcel();
$inputFileName = $uniqueName;
$inputFileType = PHPExcel_IOFactory::identify($inputFileName);
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objReader->setReadDataOnly(true);
$objPHPExcel = $objReader->load($inputFileName);
$objWorksheet = $objPHPExcel->setActiveSheetIndex(0);
$highestRow = $objWorksheet->getHighestRow();
$highestColumn = $objWorksheet->getHighestColumn();
$headingsArray = $objWorksheet->rangeToArray('A1:'.$highestColumn.'1',null, true, true, true);
$headingsArray = $headingsArray[1];
$r = -1;
$namedDataArray = array();
for ($row = 2; $row <= $highestRow; ++$row) {
$dataRow = $objWorksheet->rangeToArray('A'.$row.':'.$highestColumn.$row,null, true, true, true);
if ((isset($dataRow[$row]['A'])) && ($dataRow[$row]['A'] > '')) {
++$r;
foreach($headingsArray as $columnKey => $columnHeading) {
$namedDataArray[$r][$columnHeading] = $dataRow[$row][$columnKey];
}
}
}print_r($namedDataArray);
}
?>
<form method="post" enctype="multipart/form-data">
<label for="file">Upload</label><br>
<input type="file" name="file" id="file"><br><br>
<input type="submit" name="submit" value="Submit">
</form>
ขอบคุณครับ
Tag : PHP, MySQL, JavaScript, Ajax, jQuery

|
|
 |
 |
 |
 |
Date :
2014-04-29 22:37:09 |
By :
เด็กโง่ |
View :
944 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
1. กำหนด format cell ให้เป็น text ครับ
2. เพิ่ม ' เข้าไปข้างหน้ามันครับ เช่น '001
|
 |
 |
 |
 |
Date :
2014-04-30 09:04:24 |
By :
Manussawin |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|