Comments (8)
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.
Could you provide the code you are trying to run.
from laravel-excel.
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.
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.
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.
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.
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.
@felipesmendes Please open a new issue for it and use the issue template.
from laravel-excel.
Related Issues (20)
- [Bug]: Is an Invalid HTML file. HOT 5
- A change in ./src/Sheet.php in v3.1.47 moving WithDrawings from open to close method ignores WithHeadings headings() implementation [Bug]:
- [Bug]: No ReaderType or WriterType could be detected. Make sure you either pass a valid extension to the filename or pass an explicit type. HOT 5
- [Bug]: Import CSV to Database HOT 3
- [Bug]: Empty line error A1 in csv and excel HOT 3
- [Bug]: "Spreadsheet objects cannot be serialized" error with batch cell caching HOT 3
- [Bug]: WithColumnWidths not working with ShouldAutoSize in PDF HOT 4
- [Bug]: the column displayed in the error message is not the correct one for validation rules require_with:*.<number> HOT 2
- [Bug]: "Call to undefined function Maatwebsite\\Excel\\resolve()" HOT 2
- [Bug]: ob_end_clean(): Failed to delete buffer. No buffer to delete - after updating to 3.1.54 HOT 1
- [Bug]: ob_end_clean() Failed to delete buffer, while Exporting a file HOT 2
- [Bug]: passing `&` got the error HOT 2
- [Bug]: Escaping backslash issue HOT 1
- [Bug]: Object of class PhpOffice\PhpSpreadsheet\Calculation\Engine\Operands\StructuredReference could not be converted to string
- [Bug]: When exporting csv of more than 1001 rows, if NO header rows are used, the output file is only 1000 rows HOT 2
- [Bug]: Maatwebsite\Excel\Jobs\AppendQueryToSheet has been attempted too many times. HOT 1
- [Bug]: Conflict on date timestamp and a numeric value
- [Bug]: Array and string offset access syntax with curly braces is deprecated HOT 1
- [Bug]: Cannot install the package HOT 6
- [Bug]: Excel download not working
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-excel.