使用nuovo / spreadsheet-reader lib

时间:2018-08-05 08:42:58

标签: php phpexcel phpspreadsheet

大家好,我正在尝试使用nuovo / spreadsheet-reader在php中读取.xls文档 像这样...

<?php
require('lib/php-excel-reader/excel_reader2.php');
require('lib/SpreadsheetReader.php');

if(isset($_POST['Submit']))
{
if($_FILES["file"]["size"] > 0)
{
$uploadFilePath = 'uploads/'.basename($_FILES['file']['name']);

move_uploaded_file($_FILES['file']['tmp_name'], $uploadFilePath);
$Reader = new SpreadsheetReader($uploadFilePath);

$totalSheet = count($Reader->sheets());
echo "You have total ".$totalSheet." sheets".


for($i=0;$i<$totalSheet;$i++)
 {
 $Reader->ChangeSheet($i);
 try{
  foreach ($Reader as $Row)
  {
   $student_name=isset($Row[0]) ? $Row[0] : '';
   $SRN_number = isset($Row[1]) ? $Row[1] : '';
   $DOB = isset($Row[2]) ? $Row[2] : '';
   $year = isset($Row[3]) ? $Row[3] : '';
   $sem = isset($Row[4]) ? $Row[4] : ''; 
   echo $Row[1];
   echo $student_name;
   echo $SRN_number;
   echo $DOB;
   echo $year;
   echo $sem;
 }
}catch(Exception $e){echo "exception:-";echo $e->getMessage();}

}


echo "Data Inserted in dababase";
}
else
{
die("Sorry, File type is not allowed. Only Excel file.");
}
}echo "error";
?>

我正在得到这样的输出

您总共有1张GeneralprasadGeneral1997199719971997-JanJan-TueTueTueGeneralGeneral

我不明白为什么int值显示的是General,而日期显示的像是1997199719971997-JanJan-TueTue doc中的实际日期是(1997-01-14)
  actual xls Document
对不起,代表不好 并感谢您的帮助

0 个答案:

没有答案