Booking导入数据

<?php include "../db_user.php";?> Book订单导入

Booking导入数据

请核对以下数据,是否与excle中的一样,不能用空行。

<?php ini_set('memory_limit','640M'); set_time_limit(600); require_once "../class/main.class.php"; require_once "../PHPExcel-1.8/Classes/PHPExcel.php"; class MyExcel extends PHPExcel{ //扩展名范围 public $ext=array("xls","xlsx"); //导入文件是否合法 public function valid($str){ $y=1; //取后半扩展名 $str=explode(".",$str);
			foreach($this->ext as $key =>$value){
				if(!strcmp($str[1],$value)){$y=0;}	
			}
			return $y;
		}//valid
		//解析excel
		public function read($f){
			//从文件加载excel
			$excel=PHPExcel_IOFactory::load($f);
			//得到活动的工作表
			$sheet=$excel->getActiveSheet();
			/**读取excel文件中的第一个工作表*/ 
			$currentSheet = $excel->getSheet(0); 				
			//得到有几条数据
			$highestRow=$sheet->getHighestRow();
			//循环读取数据
			//因为第一行是标题,所以从2开始
			
			$highestColumn = $sheet->getHighestColumn(); // 取得总列数						
		
			$end_index=PHPExcel_Cell::columnIndexFromString($highestColumn);//列名转列数
			$arr=array();
			for ($row = 1; $row <= $highestRow; $row++){//第1行开始
				$j=0;					
			    for ($column = 0; $column <$end_index-1; $column++) {//列数是以A列开始
			//    		$cell=$sheet->getCellByColumnAndRow(ord($column) - 65,$row)->getValue();/**ord()将字符转为十进制数*/ 

			  //  	        if($cell instanceof PHPExcel_RichText){//富文本转换字符串  
        			//			$cell = $cell->__toString();
        			//		}
					$col_name=PHPExcel_Cell::stringFromColumnIndex($column);
			$cell=$sheet->getCell($col_name.$row)->getFormattedValue();
			    	$arr[$row][$j] = $cell;
			    	$j++;
			    }
			}				
			return $arr;
		}//read

public function insertD($array,$number,$operator){
	$count=0;
	$total=0;;

	//insert into db
	$M=new Main();

d a t e = date= date=M->date();
foreach($array as $t){

		$arr=array();
		$arr["number"]=$number;

a r r [ &quot; c u s t o m e r &quot; ] = a d d s l a s h e s ( arr[&quot;customer&quot;]=addslashes( arr["customer"]=addslashes(t[0]); a r r [ &quot; s u p p l i e r &quot; ] = a d d s l a s h e s ( arr[&quot;supplier&quot;]=addslashes( arr["supplier"]=addslashes(t[1]); a r r [ &quot; o r d e r N u m b e r &quot; ] = &quot; &quot; ; arr[&quot;orderNumber&quot;]=&quot;&quot;; arr["orderNumber"]="";arr[“materialCode”]=addslashes(""); a r r [ &quot; c a r t o n N u m b e r &quot; ] = &quot; &quot; ; arr[&quot;cartonNumber&quot;]=&quot;&quot;; arr["cartonNumber"]="";arr[“PONumber”]=addslashes( t [ 3 ] ) ; t[3]); t[3]);arr[“productName”]=addslashes(""); a r r [ &quot; p r o d u c t C o d e &quot; ] = &quot; &quot; ; arr[&quot;productCode&quot;]=&quot;&quot;; arr["productCode"]="";arr[“SKU”]=addslashes( t [ 4 ] ) ; t[4]); t[4]);arr[“SKUName”]=""; a r r [ &quot; U P C &quot; ] = a d d s l a s h e s ( arr[&quot;UPC&quot;]=addslashes( arr["UPC"]=addslashes(t[9]); a r r [ &quot; f a c t o r y &quot; ] = a d d s l a s h e s ( arr[&quot;factory&quot;]=addslashes( arr["factory"]=addslashes(t[2]); a r r [ &quot; d e s c r i p t i o n &quot; ] = a d d s l a s h e s ( arr[&quot;description&quot;]=addslashes( arr["description"]=addslashes(t[11]); a r r [ &quot; s t y l e &quot; ] = a d d s l a s h e s ( arr[&quot;style&quot;]=addslashes( arr["style"]=addslashes(t[5]); a r r [ &quot; s t y l e N a m e &quot; ] = a d d s l a s h e s ( arr[&quot;styleName&quot;]=addslashes( arr["styleName"]=addslashes(t[10]); a r r [ &quot; C O O &quot; ] = a d d s l a s h e s ( arr[&quot;COO&quot;]=addslashes( arr["COO"]=addslashes(t[17]); a r r [ &quot; l o t &quot; ] = a d d s l a s h e s ( arr[&quot;lot&quot;]=addslashes( arr["lot"]=addslashes(t[14]); a r r [ &quot; c o l o r &quot; ] = a d d s l a s h e s ( arr[&quot;color&quot;]=addslashes( arr["color"]=addslashes(t[6]); a r r [ &quot; c o l o r C o d e &quot; ] = a d d s l a s h e s ( arr[&quot;colorCode&quot;]=addslashes( arr["colorCode"]=addslashes(t[7]); a r r [ &quot; s i z e &quot; ] = a d d s l a s h e s ( arr[&quot;size&quot;]=addslashes( arr["size"]=addslashes(t[8]); a r r [ &quot; o t h e r s &quot; ] = &quot; &quot; ; arr[&quot;others&quot;]=&quot;&quot;; arr["others"]="";arr[“length”]=""; a r r [ &quot; w i d t h &quot; ] = &quot; &quot; ; arr[&quot;width&quot;]=&quot;&quot;; arr["width"]="";arr[“height”]=""; a r r [ &quot; w e i g h t G &quot; ] = &quot; &quot; ; arr[&quot;weightG&quot;]=&quot;&quot;; arr["weightG"]="";arr[“weightN”]=""; a r r [ &quot; v o l u m e &quot; ] = &quot; &quot; ; arr[&quot;volume&quot;]=&quot;&quot;; arr["volume"]="";arr[“price”]= t [ 15 ] ; t[15]; t[15];arr[“currency”]=addslashes( t [ 16 ] ) ; t[16]); t[16]);arr[“qtyPerCarton”]=""; a r r [ &quot; q t y &quot; ] = arr[&quot;qty&quot;]= arr["qty"]=t[12]; a r r [ &quot; r e c e i v e d Q t y &quot; ] = &quot; &quot; ; arr[&quot;receivedQty&quot;]=&quot;&quot;; arr["receivedQty"]="";arr[“receivedDate”]=addslashes( t [ 13 ] ) ; t[13]); t[13]);arr[“created”]= d a t e ; date; date;arr[“remark”]=addslashes($t[18]);

		$arr["operator"]=$operator;

		if($M->insert("order_detail",$arr)){//插入成功了
			$count++;
		}//if
		$total++;
	}//foreach
	echo "<script>alert('共有".$total."条数据,成功导入".$count."条.');window.location.href='../orderInput.php';</script>";
}//insert

}//Excel

$value=array();
$i=1;
if(isset($_POST["leadExcel"])){		
	//1.是不是excle
	$obj=new MyExcel();
	if($obj->valid($_FILES['fileName']['name'])){

// exit ‘<script">alert(“Only accept excel file!”);window.history.back();’;
}
//2.从第二行开始读
v a l u e = value= value=obj->read($_FILES[‘fileName’][‘tmp_name’]);
S E S S I O N [ ′ d a t a ′ ] = s e r i a l i z e ( _SESSION[&#x27;data&#x27;] = serialize( SESSION[data]=serialize(value);

t i t l e = &quot; &lt; t h &gt; 行 &lt; / t h &gt; &quot; ; f o r ( title=&quot;&lt;th&gt;行&lt;/th&gt;&quot;; for( title="<th></th>";for(t=0; t &lt; 31 ; t&lt;31; t<31;t++){
if($t<26){
t i t l e . = &quot; &lt; t h &gt; &quot; . c h r ( 65 + title.=&quot;&lt;th&gt;&quot;.chr(65+ title.="<th>".chr(65+t)."";
}else{
t i t l e . = &quot; &lt; t h &gt; A &quot; . c h r ( title.=&quot;&lt;th&gt;A&quot;.chr( title.="<th>A".chr(t+39)."";
}//if
}//for
echo ‘

’. t i t l e . ′ &lt; / t r &gt; ′ ; f o r e a c h ( title.&#x27;&lt;/tr&gt;&#x27;; foreach ( title.</tr>;foreach(value as $key => KaTeX parse error: Expected '}', got 'EOF' at end of input: …ho '<tr><td>'.(i++).’’;
foreach($value AS k = &gt; k=&gt; k=>v){
echo ‘’;
}//foreach
echo ‘’;
}//foreach
echo ‘
’. v a l u e [ value[ value[k].’
’;
}//for
?>

系统订单号:<?=$_REQUEST["systemBookNumber"];?>

if(isset($_GET[‘m’])){

$objIn=new MyExcel();
$objIn->insertD(unserialize($_SESSION['data']),$_REQUEST["systemBookNumber"],$user);

$_SESSION['data']=NULL;
unset($_GET['m']);
unset($_SESSION['data']);

}
?>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值