此代码在导入.xls文件时工作正常..但是当我们上传.xlsx时,它会显示一些错误,例如"名称不可读" ..任何人都可以告诉一些解决方案来解决这个问题吗? ?
这是我的代码......
include("includes/config.php");
if ($_POST['frmSubmit']) {
$fileName = $_FILES['frmUpload']['tmp_name'];
if ($fileName) {
$data = new Spreadsheet_Excel_Reader();
$data->read($fileName);
$strDatas = $data->sheets[0]['numRows'];
$strDataCount = 0;
$strInsertRecords = 0;
$strDuplicationRecords = 0;
for($k=2; $k<=$strDatas; $k++) {
$strData = $data->sheets[0]['cells'][$k];
$strTableColumn = count($strData);
if ($strTableColumn == 7) {
$strStatus = doCheckDuplication($strData['3']);
if ($strStatus == 0) {
doInsertEmployeeDetails($strData[1], $strData[2], $strData[3], $strData[4], $strData[5], $strData[6], $strData[7]);
$strInsertRecords++;
} else {
$strDuplicationRecords++;
}
$strDataCount++;
if ($strDataCount == $strInsertRecords) {
$strMessage = 'Employee record(s) inserted successfully!';
$strClass = 'Success';
}
if ($strDataCount != $strInsertRecords) {
$strMessage = 'Employee record(s) inserted successfully but some of record(s) are already exists.!';
$strClass = 'Error';
}
if ($strDataCount == $strDuplicationRecords) {
$strMessage = 'Employee record(s) are already exists.!';
$strClass = 'Error';
}
} else {
$strMessage = 'Column mis-match, Please verify the file.';
$strClass = 'Error';
}
}
} else {
$strMessage = 'Please upload a valid file.';
$strClass = 'Error';
}
}