search

Home  >  Q&A  >  body text

Please tell me, teacher, why is there no error message and no download response?

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<body>

<? php

$r1r = implode(",",$_POST['ypname']);

$r2r = implode(",",$_POST['guige'] );

$r3r = implode(",",$_POST['shengcan']);

$r4r = implode(",",$_POST['danwei']);

$r5r = implode(",",$_POST['pihao']);

$r6r = implode(",",$_POST['bz']);

$r7r = implode(",",$_POST['rq']);

$r8r = implode(",",$_POST['djlx']);

$r9r = implode(",",$_POST['rk']);

$rwr = implode(",",$_POST['ch']);


$data2 = array_merge($r1r,$r2r);

var_dump ($data2);

/**

* Data export

* @param array $title Title row name

* @param array $data Export data

* @param string $fileName File name

* @param string $savePath Save path

* @param $type Whether to download false--save true--download

* @return string Return the full file Path

* @throws PHPExcel_Exception

* @throws PHPExcel_Reader_Exception

*/

$title = array("Product name", "Specification", "Manufacturer", "Unit", "Batch number", "Remarks", "Date", "Document type", "Inbound quantity", "Export quantity" Quantity");

$type = true;

$data = r1r;

$fileName = 'bflxexc';

function exportExcel($title=array(), $data=array(), $fileName='', $savePath='./', $isDown=false){

include('PHPExcel. php');

$obj = new PHPExcel();

//Horizontal cell identification

$cellName = array('A' , 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', ' N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' , 'AA', 'AB', 'AC', 'AD', 'AE', 'AF', 'AG', 'AH', 'AI', 'AJ', 'AK', 'AL', ' AM', 'AN', 'AO', 'AP', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AV', 'AW', 'AX', 'AY' , 'AZ');

$obj->getActiveSheet(0)->setTitle('bflx'); //Set sheet name

$_row = 1; //Set vertical cell identifier

if($title){

$_cnt = count($title);

$obj->getActiveSheet(0)->mergeCells('A'.$_row.':'.$cellName[$_cnt-1].$_row); //Merge cells

$obj->setActiveSheetIndex(0)->setCellValue('A'.$_row, '$r1r'.date('Y-m-d H:i:s')); //Set the merged cell content

$_row ;

$i = 0;

foreach($title AS $v){ //Set column title

$obj-> ;setActiveSheetIndex(0)->setCellValue($cellName[$i].$_row, $v);

$i ;

}

$_row ;

}

//Fill in the data

if($data){

$i = 0;

foreach($data AS $_v){

$j = 0;

foreach($_v AS $_cell){

$obj->getActiveSheet(0 )->setCellValue($cellName[$j] . ($i $_row), $_cell);

$j ;

}

$i ;

}

}

//File name processing

if(!$fileName){

$ fileName = uniqid(time(),true);

}

$objWrite = PHPExcel_IOFactory::createWriter($obj, 'Excel2007');

if($isDown){ //Webpage download

header('pragma:public');

header("Content-Disposition:attachment;filename= $fileName.xls");

$objWrite->save('php://output');exit;

}

$_fileName = iconv("utf-8", "gb2312", $fileName); //Transcoding

$_savePath = $savePath.$_fileName.'.xlsx';

$ objWrite->save($_savePath);

return $savePath.$fileName.'.xlsx';

}

//exportExcel (array('name','age'), array(array('a',21),array('b',23)), 'file', './', true);

?>

</body>

<?php

?>

//The array is still There is no conversion, but why is there no prompt to download?

奥立奥奥立奥2333 days ago1219

reply all(4)I'll reply

  • 、馬

    、馬2018-07-10 17:48:28

    Is there any problem with the path

    reply
    0
  • 奥立奥

    include('PHPExcel.php');Is this the path? I added ./ but it didn't work.

    奥立奥 · 2018-07-10 22:51:04
  • 奥立奥

    奥立奥2018-07-10 17:07:59

    Every post has value

    reply
    0
  • 、馬

    Yes

    、馬 · 2018-07-10 17:47:09
  • Cancelreply