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

0

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
<?php
require_once __DIR__.'/vendor/autoload.php';
header('Content-Type: text/html');
use Jaspersoft\Client\Client;
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
  $sentControls = array();
  foreach ($_POST as $key => $value) {
    switch ($key) {
      case 'uri':
      $uri = htmlentities($value);
      break;
      case 'name':
      $currentReportName = htmlentities($value);
      break;
      case 'format':
      $format = htmlentities($value);
      break;            
      default:
      $sentControls[$key][] = $value;
      break;
    }
  }
} 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(
  'localhost:8080/jasperserver',
  'jasperadmin',
  'jasperadmin',
  ''
);  
$client->setRequestTimeout(90000);
 
$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;       
  die();
 }
 
 
 
?>
 
 
<!DOCTYPE html PUBLIC "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<title>Tanamduit</title>
 
 
<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>
   </select>             
   <input type="submit" value="Export">
 </form><hr/> 
</div>
 
<div class="col-md-9">
 <div class="card example-1 scrollbar-ripe-malinka" style="height:500px">
   <div class="card-body">
    <?php
    // echo $screen; 
    echo $report;
  </div>
</div>
</div>  
</html>
r code here..

andryfreddyh's picture
Joined: Sep 16 2019 - 8:58pm
Last seen: 1 week 4 days ago

0 Answers:

No answers yet
Feedback
randomness