Giter Site home page Giter Site logo

Comments (8)

MaatwebsiteSupport avatar MaatwebsiteSupport commented on May 3, 2024 4

Are you sure you are using the last version of the package? (https://github.com/Maatwebsite/laravel4-PHPExcel/blob/master/src/Maatwebsite/Excel/Readers/HTML_reader.php#L193)
The dom loadHTML is already silenced.

A while back we got an issue with the '&'-sign. Silencing the loadHTML which kind of solved the issue. But it will not fix the problem, it will only hide the warnings.

A better fix is to use the html equivalent of '&', which is &
Best is to escape the echo in which these characters appear. You can use the blade syntax with the tripple braces( {{{ }}} )

from laravel-excel.

MaatwebsiteSupport avatar MaatwebsiteSupport commented on May 3, 2024

Could you provide the code you are trying to run.

from laravel-excel.

mdeprezzo avatar mdeprezzo commented on May 3, 2024

Sure,

// Load HTML from string
$loaded = $dom->loadHTML(mb_convert_encoding($pFilename, 'HTML-ENTITIES', 'UTF-8'));

This is the function inside the Readers class,

In a controller i've this call:

        Excel::loadView('admin.clients.folder.format', array('data' => $clients))
            ->setTitle('Clienti')
            ->sheet('Lista Clienti')
            ->export('xls');

i cant post the html code, but i notice that when i've some htmlentities like '& agrave ;' or similar i got this error. And if i try to sopprime with '@' before loadHTML call, in that cell with htmlentities data i see FALSE

from laravel-excel.

mdeprezzo avatar mdeprezzo commented on May 3, 2024

Ok, i've update with the last version of this package. But like u said the problem still remains.
I'll try to use the equivalent of & in html entities, but i need to convert all the entities à, because if i just convert o replace & with & the html conversion of à character doesn't works

Why i've problem with accents ? What's wrong with that ?

Silencing the loadHTML for me doesn't works, so i'm crazy for that solution.

from laravel-excel.

mdeprezzo avatar mdeprezzo commented on May 3, 2024

I've an update. I'm trying to load on my webserver the new package, and works perfect. On localhost i've that error. So excuse me guys. Maybe some settings about php ?

from laravel-excel.

MaatwebsiteSupport avatar MaatwebsiteSupport commented on May 3, 2024

Try throwing away the vendor folder and the composer.lock file on your localhost. Then do composer install. The latest version of the package should be installed.

from laravel-excel.

felipesmendes avatar felipesmendes commented on May 3, 2024

I'm with the same error and here is my code:

Controller Call:

       return Excel::download(new PosicoesExport($posicoes, $logo, $vet_campos, $clientes, $veiculos, $rastreadores, $motivos_transmissao),$posicoes[0]->veiculo->placa." - ".$posicoes[0]->veiculo->cliente->nome.".csv", \Maatwebsite\Excel\Excel::CSV);

Export:

<?php
namespace App\Exports;

use App\Posicao;
use Illuminate\Contracts\View\View;
use Maatwebsite\Excel\Concerns\FromView;
use Maatwebsite\Excel\Concerns\WithCustomCsvSettings;

class PosicoesExport implements FromView,WithCustomCsvSettings
{
    public function __construct($posicoes, $logo, $campos, $clientes, $veiculos, $rastreadores, $motivos_transmissao){
        $this->dados = compact('posicoes','logo','campos','clientes','veiculos','rastreadores','motivos_transmissao');
    }
    public function view(): View
    {
        return view('posicao.posicaoexcel', $this->dados);
    }
     
    public function getCsvSettings(): array
    {
        return [
            'use_bom' => true
        ];
    }
   
}
?>

View:

<html>
    <tr align="center">
        <th>Veículo</th>
        <th>Data</th>
        @if(!empty($campos))
        @foreach ($campos as $campo)
        @if($campo['listar'])
        <th>{{{$campo['label']}}}</th>
        @endif
        @endforeach
        @endif
    </tr>
    @foreach ($posicoes as $posicao)
    <tr align="center">
        <td>{{{$posicao->veiculo->placa}}}</td>
        <td>@datetime($posicao->data_recebimento)</td>
        @foreach ($campos as $campo)
        @if($campo['listar'])
        @if($campo['valor'] == 'cliente')
        <td>{{{$posicao->cliente->nome}}}</td>
        @elseif($campo['valor'] == 'veiculo')
        <td>{{{$posicao->veiculo->placa}}}</td>
        @elseif($campo['valor'] == 'velocidade')
            <?php 
            $flag = "";
            $vel = 0;
            if (isset($posicao->velocidade)) {
                $vel = $posicao->velocidade;
            } else {
                $vel = 0;
            }

            if (is_null($posicao->ignicao) || $posicao->ignicao != 1) {
                $vel = 0;
                $flag = "background-color:#000000;color:#FFFFFF;";
            } else {
                if ($vel == 0)
                    $flag = "background-color:#CCCCCC;color:#000000;";
                else if ($vel <= 20)
                    $flag = "background-color:##45a7e8;color:#000000;";
                else if ($vel <= 40)
                    $flag = "background-color:#0000FF;color:#FFFFFF;";
                else if ($vel <= 60)
                    $flag = "background-color:#00FF00;color:#000000;";
                else if ($vel <= 80)
                    $flag = "background-color:#FFFF00;color:#000000;";
                else if ($vel <= 100)
                    $flag = "background-color:#FFA500;color:#000000;";
                else
                    $flag = "background-color:#a333c8;color:#FFFFFF;";
                    // $flag = "background-color:#FF0000;color:#FFFFFF;";
                
            }
            echo "<td style=\"$flag\" >$vel</td>";
            ?>
        @elseif($campo['valor'] == 'rastreador')
        <td>{{{$posicao->rastreador->identificador}}}</td>
        @elseif($campo['valor'] == 'data_recebimento')
        <td>@datetime($posicao->data_recebimento)</td>
        @elseif($campo['valor'] == 'created_at')
        <td>@datetime($posicao->created_at)</td>
        @elseif($campo['valor'] == 'motivo_transmissao')
        <td>@if(is_object($posicao->motivo)){{{$posicao->motivo->nome}}}@endif</td>
        @elseif($campo['valor'] == 'latitude')
        <td>{{{str_replace(',','.',$posicao->latitude)}}}</td>
        @elseif($campo['valor'] == 'longitude')
        <td>{{{str_replace(',','.',$posicao->longitude)}}}</td>
        @elseif($campo['valor'] == 'descricao')
            <td>
                {{{$posicao->veiculo->descricao}}}
            </td>
        @elseif($campo['valor'] == 'local_cerca_id')
            @if($posicao->posicao_id)
            <td>
                @foreach($posicao->local($posicao->posicao_id) as $cerca_loi)
                    <span class="item">{{{$cerca_loi["local_cerca"]}}}</span> - 
                @endforeach
            </td>
            @else
            <td> -- </td>
            @endif
        @elseif($campo['valor'] == 'velocidade_maxima_seco')
            @if($posicao->posicao_id)
                <td>
                    @foreach($posicao->local($posicao->posicao_id) as $cerca_loi)
                        @if($cerca_loi["flg_tipo"] == 1)
                        <span class="item">{{{$cerca_loi["velocidade_maxima_seco"]}}}</span> - 
                        @endif
                    @endforeach
                </td>
            @else
                <td></td>
            @endif
        @elseif($campo['valor'] == 'velocidade_maxima_chuva')
            @if($posicao->posicao_id)
                <td>
                    @foreach($posicao->local($posicao->posicao_id) as $cerca_loi)
                        @if($cerca_loi["flg_tipo"] == 1)
                        <span class="item">{{{$cerca_loi["velocidade_maxima_chuva"]}}}</span> - 
                        @endif 
                    @endforeach
                </td>
            @else
                <td></td>
            @endif
        @else
        <td><?php echo $posicao->{$campo['valor']} ?></td>
        @endif
        @endif
        @endforeach
    </tr>
    @endforeach

</html>

from laravel-excel.

GlennM avatar GlennM commented on May 3, 2024

@felipesmendes Please open a new issue for it and use the issue template.

from laravel-excel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.