SIMITGROUP / phpjasperxml

This is a php wysiwyg report library
BSD 3-Clause "New" or "Revised" License
44 stars 45 forks source link

Erro to use Class phpjasperxml #92

Closed elidorio closed 6 months ago

elidorio commented 9 months ago

I am unable to use the PHPJASPERXML class. I don't know what's wrong in my code! I'm using it with php, pdo and postgressql database.

<?php $server="localhost"; $db="projetox"; $user="postgres"; $pass="xxxx555"; $cndriver="psql"; $pgport=5432;

?>

<?php date_default_timezone_set('America/Sao_Paulo');

include_once 'config/setting.php'; //include_once 'PHPJasperXML/src/PHPJasperXML.php'; //include_once 'PHPJasperXML/vendor/composer';

require_once 'PHPJasperXML/vendor/autoload.php';

use simitsdk\phpjasperxml\PHPJasperXML;

$filename = 'rep/cadcidade.jasper'; file:///opt/lampp/htdocs/projetox/relcadcidade.php

$report = new PHPJasperXML();

try { $report->load_xml_file($filename) ->setParameter(['reporttitle' => 'Database Report With Driver : ' . $config['driver']]) ->setDataSource($config) ->export('Pdf');

echo 'Relatório gerado com sucesso!';

} catch (\Exception $e) { echo 'Erro ao gerar relatório: ' . $e->getMessage(); } ?>

kstan79 commented 9 months ago

What it show, beside it is pdf why you echo something?

Have you check sample report and is it work well in your computer?

elidorio commented 9 months ago

phpjasper.zip Now, I managed to put together a report, the problem is in displaying the data, the script is not sending the sql assembled in the script to the report, but rather getting the sql from the report itself without any filter.

kstan79 commented 9 months ago

add ->setQueryString($sql) before export('pdf')

elidorio commented 9 months ago

It didn't solve it, the problem still persists.

kstan79 commented 8 months ago

according to code PHPJasperXML_load, the setQueryString() execute within load_xml_file/load_xml_string.

Your execution ofsetQueryString() by right will replace build in sql, just ensure it run after load_xml_file/load_xml_string.

If you still failed, you may debug within PHPJasperXML_load.php in your vendor

kstan79 commented 6 months ago

close due to no feed back