我已经使用PHP excel读取了excel文件。
但是该excel文件包含一些日期(时间格式),PHP excel在这种情况下返回错误的值
$allowedExtensions = array("xls","xlsx");
$ext = pathinfo('uploads/APP_abeesycs_ew.xlsx', PATHINFO_EXTENSION);
if(in_array($ext, $allowedExtensions)) {
$file_size = "uploads/APP_abeesycs_ew.xlsx"/ 1024;
if($file_size < 50000) {
error_reporting(E_ALL);
$file = 'uploads/APP_abeesycs_ew.xlsx';
$isUploaded = copy('uploads/APP_abeesycs_ew.xlsx', $file);
include("Classes/PHPExcel/IOFactory.php");
try {
//Load the excel(.xls/.xlsx) file
$objPHPExcel = PHPExcel_IOFactory::load($file);
} catch (Exception $e) {
die('Error loading file "' . pathinfo($file, PATHINFO_BASENAME). '": ' . $e->getMessage());
}
ini_set('memory_limit','3072M');
$cacheSettings = array( ' memoryCacheSize ' => '8MB');
$sheet = $objPHPExcel->getSheet(0);
$total_rows = $sheet->getHighestRow();
$highest_column = $sheet->getHighestColumn();
'<h4>Data from excel file</h4>';
$query = "insert into `complaindetail` (`Tno` ,`ComplNo` ,`ComplDate` ,`InvNo` ,`CustName` ,`CustAddress` ,`CustArea` ,`CustNo` ,`SrNo` ,`ProductCode` ,`ItemName` ,`Qty`,`Rate`,`Amount`,`Noofservice`,`ServiceType`,`ProblemSummery`,`UserName`,`UserDate`,`UserTime`,`Slocation`,`ODUSrno`,`IDUSrno`,`ProductType`,`BrandName`,`Capacity`,`EngineerName`,`ComplainStatus`) VALUES ";
for($row =1; $row <= $total_rows; $row++) {
$single_row = $sheet->rangeToArray('A' . $row . ':' . $highest_column . $row, NULL, TRUE, FALSE);
//echo "<tr>";
//Creating a dynamic query based on the rows from the excel file
$query .= "(";
//Print each cell of the current row
foreach($single_row[0] as $key=>$value) {
//echo "<td>".$value."</td>";
$query .= "'".mysqli_real_escape_string($con, $value)."',";
}
$query = substr($query, 0, -1);
$query .= "),";
}
$query = substr($query, 0, -1);
mysqli_query($con, $query);
if(mysqli_affected_rows($con) > 0) {
echo "ledgerbalancedetailreport";
} else {
echo '<span class="msg">Can\'t update ledgerbalancedetailreport</span>';
}
} else {
echo '<span class="msg">Maximum file size should not cross 50 KB on size!</span>';
}
} else {
echo '<span class="msg">This type of file not allowed!</span>';
}
任何人都可以帮助实现这一点。.在PHPExcel中对此案例具有一些特定功能。
我的输入excel文件在下面
2013-12-12、2013-12-13
我的输出在下面
41621,41631
有一些隐秘的日期格式输出数据的方法吗?
答案 0 :(得分:0)
Excel以1900年以来的天数存储日期。只需使用以下方法将1900年的天数增加41621/41631天即可: