简介:
public function setEncode($incode,$outcode){
$this->inEncode=$incode;
$this->outEncode=$outcode;
}
public function setTitle($titlearr){
$title="";
foreach($titlearr as $v){
if($this->inEncode!=$this->outEncode){
$title.=iconv($this->inEncode,$this->outEncode,$v)."\t";
}
else{
$title.=$v."\t";
}
}
$title.="\n";
return $title;
}
使用方法
$excel=new Excel();
设置编码:
$excel->setEncode("utf-8","gb2312"); //如果不转码,参数写一样即可,例如$excel->setEncode("utf-8","utf-8");
设置标题栏
$titlearr=array("a","b","c","d");
设置内容栏
$contentarr=array(
1=>array("ab","ac","ad","ae"),
2=>array("abc","acc","adc","aec"),
3=>array("abd","acd","add","aed"),
4=>array("abe","ace","ade","aee"),
);
$excel->getExcel($titlearr,$contentarr,"abc");