<?php
namespace lib\excel;
/**
 * excel
 * @author HzqGhost admin@whiledo.com QQ:313143468
 * @version 1.0.0
 *
 */
class excel implements \lib\excel\excelInterface
{
    private $excel = null;
	public function __construct($type)
    {
        $this->excel = make('\lib\excel\excel'.ucfirst($type));
    }
    /*
	public function __call($method,$params)
    {
        return call_user_func_array([$this->excel,$method],$params);
    }*/
    public function setConstMemory(bool $constMemory):excelInterface{
	    return $this->excel->setConstMemory($constMemory);
    }
    public function setDirFile(string $fullfilename):excelInterface{
	    return $this->excel->setDirFile($fullfilename);
    }
	public function setDir(string $dirname):excelInterface{
	    return $this->excel->setDir($dirname);
	}
	public function setFile(string $filename):excelInterface{
	    return $this->excel->setFile($filename);
	}
	public function setStream($fp, string $filename):excelInterface{
	    return $this->excel->setStream($fp,$filename);
	}
	public function formatSheetName(string $sheetName):string{
	    return $this->excel->formatSheetName($sheetName);
	}
	public function formatFileName(string $filename):string{
	    return $this->excel->formatFileName($filename);
	}
	public function header(string $outFilename=''):excelInterface{
        return $this->excel->header($outFilename);
    }
    public function bookBegin():excelInterface{
        return $this->excel->bookBegin();
    }
    public function bookEnd(){
        return $this->excel->bookEnd();
    }
    public function formatHeaderRow(array $HeaderFields){
        $data = [];
        foreach($HeaderFields as $k=>$v){
            $data[$k] = $v[0];
        }
        return $data;
    }
    public function formatColumnStyle(array $HeaderFields){
        $data = [];
        foreach($HeaderFields as $k=>$v){
            $data[$k] = $v[1];
        }
        return $data;
    }
    public function sheetBegin(string $sheetName,array $headerRow=[],array $columnStyle=[]):excelInterface{
        return $this->excel->sheetBegin($sheetName,$headerRow,$columnStyle);
    }
    public function sheetEnd():excelInterface{
        return $this->excel->sheetEnd();
    }
    public function append(array $row=[]):excelInterface{
        return $this->excel->append($row);
    }
    public function each($callback,$sheetName=null){
        return $this->excel->each($callback,$sheetName);
    }
    public function toArray($types=[]):array{
        return $this->excel->toArray($types);
    }
    public function toCsv($dist):bool{
        return $this->excel->toCsv($dist);
    }
    public function zipFile(array $filelist,string $zipfile, bool $isDelete=true):excelInterface{
        return $this->excel->zipFile($filelist,$zipfile, $isDelete);
    }
}