时间:2021-07-01 10:21:17 帮助过:22人阅读
error_reporting(E_ALL ^ E_NOTICE);
if($_POST){
$Import_TmpFile = $_FILES['file']['tmp_name'];
require_once '../../inc/connect.php';
require_once 'Excel/reader.php';
$data = new Spreadsheet_Excel_Reader();
$data->setOutputEncoding('GB2312');
$data->read($Import_TmpFile);
$array =array();
for ($i = 1; $i <= $data->sheets[0]['numRows']; $i++) {
for ($j = 1; $j <= $data->sheets[0]['numCols']; $j++) {
$array[$i][$j] = $data->sheets[0]['cells'][$i][$j];
}
}
sava_data($array);
}
function sava_data($array){
$count =0;
$total =0;
foreach( $array as $tmp){
$Isql = "Select inte_card from gx_integral where inte_card='".$tmp[2]."'";
$sql = "Insert into gx_integral(inte_name,inte_card,inte_status,inte_integral,inte_date,inte_date2,inte_tel) value(";
$sql.="'".$tmp[1]."','".$tmp[2]."','".$tmp[3]."','".$tmp[4]."','".TtoD($tmp[5])."','".TtoD($tmp[6])."','".$tmp[7]."')";
if(! mysql_num_rows(mysql_query($Isql) )){
if( mysql_query($sql) ){
$count++;
}
}
$total++;
}
echo "";
}
function TtoD($text){
$jd1900 = GregorianToJD(1, 1, 1900)-2;
$myJd = $text+$jd1900;
$myDate = JDToGregorian($myJd);
$myDate = explode('/',$myDate);
$myDateStr = str_pad($myDate[2],4,'0', STR_PAD_LEFT)."-".str_pad($myDate[0],2,'0', STR_PAD_LEFT)."-".str_pad($myDate[1],2,'0', STR_PAD_LEFT);
return $myDateStr;
}
?>
这里是用到Spreadsheet_Excel_Reader组件了,那read.php文件我就不附上了,自己下一个吧,好了最后申明本站原创转载请注明: www.111cn.cn
http://www.bkjia.com/PHPjc/630430.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/630430.htmlTechArticlestyle type=text/css !-- @import url(../style/admin.css); .STYLE1 { color: #FF0000; font-weight: bold; } .STYLE2 {color: #0033FF} -- /style script function import_check(){ var f_con...