Download report in format .xls issue with jasper reports using php client

I have implemented jasper reports using version 6.8.1 in my application with php clent integration And everything is working fine with this code and i can able to export pdf & csv files. But i am getting an issue while exporting xls file

when I export to .xls format the results are not as expected but the format is messy like this

I really appreciate and expect help from all my friends if anyone knows the solution to my problem, thank you

this is my Export Code

..insert you
require_once __DIR__.'/vendor/autoload.php';
header('Content-Type: text/html');
use Jaspersoft\Client\Client;
  $sentControls = array();
  foreach ($_POST as $key => $value) {
    switch ($key) {
      case 'uri':
      $uri = htmlentities($value);
      case 'name':
      $currentReportName = htmlentities($value);
      case 'format':
      $format = htmlentities($value);
      $sentControls[$key][] = $value;
} else {
    // First call process the GET report URI
  $uri = (isset($_GET['uri'])) ? htmlentities($_GET['uri']) : false;
  $currentReportName = '';
  $format = 'html';
$screen = '';
$_PageTitle = 'Report Viewer' ; 
$tabArray =  array();
$client = new Client(
$controls = array(
  'Start_Date' => '2019-08-01', 
  'End_Date' => '2019-08-31',
$report = $client->reportService()->runReport('/Nasabah/Test_report', $format, null, null, $controls);
if ($format == 'html') {
   $screen .= $report;       
  } else {
   header('Cache-Control: must-revalidate');
   header('Pragma: public');
  header('Content-Description: File Transfer');
  header('Content-Disposition: attachment; filename=report.' . $format );
  header('Content-Transfer-Encoding: binary');
  header('Content-Length: ' . strlen($report));
  header('Content-Type: application/' . $format);
  echo $report;       
<div class="row">
  <div class="col-md-3">
   <h3><?php echo $currentReportName; ?></h3>
   <form action="index.php" method="POST">
    <input type="hidden" name="name" value="<?php echo $currentReportName ?>">
    <select name="format">
     <option value="pdf">PDF</option>
     <option value="xls">Excel</option>
     <option value="csv">CSV</option>
   <input type="submit" value="Export">
<div class="col-md-9">
 <div class="card example-1 scrollbar-ripe-malinka" style="height:500px">
   <div class="card-body">
    // echo $screen; 
    echo $report;
r code here..

andryfreddyh's picture
Joined: Sep 16 2019 - 8:58pm
Last seen: 2 years 5 months ago

i have same problem. do you has been solve it? do you can give me your mail? really i need solve this problem.

reparacentro - 2 years 2 months ago


jpgzgz - 1 year 7 months ago

0 Answers:

No answers yet