Disadvantage with download to excel

0

The download to excel does not work for me using the phpExcel library the syntax of the project is as follows

<?
require_once(/librerias_generales/Classes/PHPExcel.php);
$objPHPExcel = new PHPExcel();

function  descargar_mov()
{
    $sql="select * from tabla_mov
    ORDER BY cuenta,c_centro_costo desc;";

    p_query($sql);
    $vectorDeConsultas[$idxDeConsultas] = $sql;
    $idxDeConsultas = $idxDeConsultas + 1;  

    $Array_mov= array();
    $x=0;

     while ($registro=ifx_fetch_row($g_idq) )
        {   
            $Array_mov[$x]['c_centro_costo']=trim($registro['c_centro_costo']);//9      
            $Array_mov[$x]['c_almacen']=trim($registro['c_almacen']);//5        
            $Array_mov[$x]['caja']=trim($registro['caja']);//5  
            $Array_mov[$x]['f_mov']=trim($registro['f_mov']);//8
            $Array_mov[$x]['forma']=trim($registro['forma']);
            $Array_mov[$x]['c_agrupacion']=trim($registro['c_agrupacion']);
            $Array_mov[$x]['vrtotal']=trim($registro['vrtotal']);
            $Array_mov[$x]['cuenta']=trim($registro['cuenta']);//6
            $Array_mov[$x]['tipo']=trim($registro['tipo']);//12

        }
        $narray = count($Array_mov);
        echo "<br>--narray-".$narray;

    $objPHPExcel->setActiveSheetIndex(0);


        $objPHPExcel->setActiveSheetIndex(0)
            ->setCellValue("A1", "CO DOC FACT")
            ->setCellValue("B1", "TIPO DOC")
            ->setCellValue("C1", "NUMERO CONSECUTIVO")
            ->setCellValue("D1", "AUXILIAR CUENTA")
            ->setCellValue("E1", "TERCERO MOVIMIENTOO")
            ->setCellValue("F1", "CO MTO")
            ->setCellValue("G1", "AUXILIAR FLUJO EFECTIVO")
            ->setCellValue("H1", "VALOR DEBITO")
            ->setCellValue("I1", "VALOR CREDITO")
            ->setCellValue("J1", "VALOR BASE")
            ->setCellValue("K1", "TIPO DOC (CH-CG-ND-NC)")
            ->setCellValue("L1", "NUMERO DOC BANCO")
            ;

        for($j=0;$j<$narray;$j++)
        {
            $fila = $j +2; 
            $base=0;

            if ($base<0)$base=$base * -1;
            $base=number_format($base,$numDecimales,".","");

            $centroDeCosto=trim($Array_mov[$j]['c_centro_costo']);
            $comprobantes_mov=trim($Array_mov[$j]['comprobantes_mov']);
            $cuenta=trim($Array_mov[$j]['cuenta']); 
            $nombre_cuenta=trim($Array_mov[$j]['nombre_cuenta']);

            echo "<br>dentro del--ciclo 2 for";


            $objPHPExcel->getActiveSheet()->setCellValue("A$fila", $centroDeCosto);
            $objPHPExcel->getActiveSheet()->setCellValue("B$fila", $comprobantes_mov);
            $objPHPExcel->getActiveSheet()->setCellValue("C$fila", $consecutivo);
            $objPHPExcel->getActiveSheet()->setCellValue("D$fila", $tercero_doc);
            $objPHPExcel->getActiveSheet()->setCellValue("E$fila", $cuenta);
            $objPHPExcel->getActiveSheet()->setCellValue("F$fila", $centroDeCosto);
            $objPHPExcel->getActiveSheet()->setCellValue("G$fila", $auxiliar_flujo);
            $objPHPExcel->getActiveSheet()->setCellValue("H$fila", $debito);
            $objPHPExcel->getActiveSheet()->setCellValue("I$fila", $credito);
            $objPHPExcel->getActiveSheet()->setCellValue("J$fila", $base);
            $objPHPExcel->getActiveSheet()->setCellValue("K$fila", $tipo_doc);
            $objPHPExcel->getActiveSheet()->setCellValue("L$fila", $fecha_actual);

        }


    $objPHPExcel->getActiveSheet()->setTitle('fileName');
    $objPHPExcel->setActiveSheetIndex(0);

    header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
    header('Content-Disposition: attachment;filename="' . $fileName . '.xlsx"');
    header('Cache-Control: max-age=0');

    $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
    $objWriter->save('php://output');

    return true;
 }

?>

Doing the test does not generate the sale or download the file. just show me this on my php page

�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������� ���� !"#�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������Oh��+'��0 X'x���� ����Interface SiesaInterface SiesaWebsaasInterface SiesaInterface SiesaWebsaas@�!��e�@�!��e� ���B�=�%r8X"1��Calibri��� � ��� � ��� � ��� � ��� � ��� � ��� � ��� � ��� � ��� � ��� � ��� � ��� � ��� � ��� � � � �����8�������������������������������3f������ff���f����������������������������������̙��̙3f�3���������fff����3f3�f333�3�3f33�333��fileName��g���� CO DOC FACTTIPO DOCNUMERO CONSECUTIVOAUXILIAR CUENTATERCERO MOVIMIENTOOCO MTOAUXILIAR FLUJO EFECTIVO VALOR DEBITO VALOR CREDITO VALOR BASETIPO DOC (CH-CG-ND-NC)NUMERO DOC BANCO ���*+������&ffffff�?'ffffff�?(�?)�?�"dXX333333�?333333�?U} � } � } G} �} l} $} "} H} l} � } �} � � � � � � � � � � �  �  �  >�@d��dgg����� ����՜.��+,��0� PXl t|��� �� interfase  Worksheet Feuilles de calculRoot Entry�������� �F�!��e��!��e� SummaryInformation(���� �F0Workbook������������ �FXDocumentSummaryInformation8������������ �F����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������

already validate the version of my php and it complies with the 5.2 +

    
asked by Norbey Martinez 17.10.2018 в 18:12
source

0 answers