Jump to content
Fórum Script Brasil

Question

Tenho a seguinte estrutura de pastas

index.php (raiz)

phpspreadsheet  ( pasta criada dentro da raiz)

.........composer.json  (arquivo solto na pasta acima)

.........composer.lock  (arquivo solto na pasta acima)

........./vendor  (pasta dentro da phpspreadsheet)

............................./ dentro da pasta vendor tem outras pastas e arquivos da biblioteca

/src/view/rrc/resultExcel.php

 

Segue o código do arquivo resultExcel.php

<?php
require_once 'request_precos.php';
// require 'vendor/autoload.php';

require '../../../phpspreadsheet/vendor/autoload.php';
 
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;

// $spreadsheet = new Spreadsheet();


$spreadsheet = new Spreadsheet();


if($_SESSION['codrepr'] == ''){
    $sheet = $spreadsheet->getActiveSheet();
    $sheet->setCellValue('A1', 'Cod. Prod');
    $sheet->setCellValue('B1', 'Descrição');
    $sheet->setCellValue('C1', 'Lista');
    $sheet->setCellValue('D1', 'Preço');
    
    $row = 2;
    foreach($_retorno as $res){
        $sheet->setCellValue('A'.$row, $res['CODPROD']);
        $sheet->setCellValue('B'.$row, $res['DESCRICAO']);
        $sheet->setCellValue('C'.$row, $res['DSLISTA']);
        $sheet->setCellValue('D'.$row, $res['preço']);
        $row++;
    }
}else{
    $sheet = $spreadsheet->getActiveSheet();
    $sheet->setCellValue('A1', 'Cod. Prod');
    $sheet->setCellValue('B1', 'Descrição');
    $sheet->setCellValue('C1', 'Preço');
    
    $row = 2;
    foreach($_retorno as $res){
        $sheet->setCellValue('A'.$row, $res['CODPROD']);
        $sheet->setCellValue('B'.$row, $res['DESCRICAO']);
        $sheet->setCellValue('C'.$row, $res['preço']);
        $row++;
    }
 }
$spreadsheet->getActiveSheet()->setTitle("Cons_Preço");
$arquivo = "cons_preco".time().".xlsx";
$writer = new Xlsx($spreadsheet);
//$writer->save('arquivosXLS/'.$arquivo);
$writer->save('../../../../temp/'.$arquivo);

?>

<div class="row">
    <div class="col-lg-12">
            <?php
                $caminho = $_SERVER['HTTP_REFERER'];
                $auxcaminho= explode('/',$caminho);
                $aux1 = $auxcaminho[0];
                $aux2 = $auxcaminho[1];
                $aux3 = $auxcaminho[2];
                $aux4 = $auxcaminho[3];
                $caminhoReal = $aux1."//".$aux2."/".$aux3."/".$aux4;

                if( $_SERVER["SERVER_NAME"] == 'localhost'){
            ?>
                <a class="btn btn-primary"
                href="http://localhost:8080/painel/temp/<?php echo $arquivo; ?>" 
                download>
                <i class="fa fa-folder-open-o"></i> Fazer o  download
                </a>
            <?php
                }else{
            ?>
                <a class="btn btn-primary"
                href="<?php echo $caminhoReal; ?>/temp/<?php echo $arquivo; ?>" 
                download>
                <i class="fa fa-folder-open-o"></i> Fazer o  download
                </a>
        <?php
            }
        ?>    
    </div>
</div>

 

ao executar a geração do excel aparece as seguintes informações:

( ! ) Warning: require(../../../phpspreadsheet/vendor/autoload.php): failed to open stream: No such file or directory in C:\wamp64\www\painel\src\view\rrc\resultPrecosXLS.php on line 5

( ! ) Fatal error: require(): Failed opening required '../../../phpspreadsheet/vendor/autoload.php' (include_path='.;C:\php\pear') in C:\wamp64\www\painel\src\view\rrc\resultPrecosXLS.php on line 5

Se alguém puder me ajudar a entender o q esta acontecendo agradeço.

Se precisarem de mais ou melhores informações me avisem tambem.

 

Obrigado...

Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      149422
    • Total Posts
      645925
×
×
  • Create New...