Pengaturan

Gambar

Lainnya

Tentang KASKUS

Pusat Bantuan

Hubungi Kami

KASKUS Plus

© 2024 KASKUS, PT Darta Media Indonesia. All rights reserved

okzfaruoqiAvatar border
TS
okzfaruoqi
Zend Framework Lounge
Zend Framework
Quote:


Rule in here
:

Spoiler for "Rule":


Quote:


e book Zend Framework yang ane punya:

Quote:



tambahan lagi video tutorial integrasi ZF ma netbeans gan,jdi editornya netbeans :
Quote:




Quote:


download Zend Framework :
Quote:




Langkah Langkah menguasai Zend Framework :
Quote:


Quote:




Index Tutorial


Quote:


Quote:



regards...
*nb : tolong rate ya gan biar tambah awet ne lapak ...

emoticon-thumbsup

*thanks juga yg udh ngasih ijo ... emoticon-thumbsupemoticon-Big Grin


Zend Framework Lounge
0
47.4K
1.1K
GuestAvatar border
Komentar yang asik ya
Tampilkan semua post
PusHm0vAvatar border
PusHm0v
#142
Make Jasper Report dengan Zend Framework
Coba sharing gimana make/manggil jasper dari Zend dengan library PHPJavaBridge emoticon-Smilie

PHP Code:
class JasperController extends Zend_Controller_Action
{
    private 
$reportPath
    private 
$javaOutputStream
    private 
$dbhost,$dbname,$dbuser,$dbpass;
    
    public function 
init()
    {        
        
$options $this->getInvokeArg('bootstrap&#039/;)/->getOptions();
        
        
$this->reportPath $options['jasper']['reportPath']; //directory/folder file jasper ( .jrmxl )
        
$this->javaBridge $options['jasper']['javaBridge']; //directory / folder library PHP JavaBridge
        
        
$this->dbhost $options['resources']['db']['params']['host']; //hostname database
        
$this->dbname $options['resources']['db']['params']['dbname']; //nama database
        
$this->dbuser $options['resources']['db']['params']['username']; //user database
        
$this->dbpass $options['resources']['db']['params']['password']; //password database

        
include_once($this->javaBridge."java/Java.inc");
        
        
$this->javaOutputStream = new java("java.io.ByteArrayOutputStream");
    }


private function getParam($params)
    {
        
$newParam = new Java("java.util.HashMap");
        foreach (
$params as $param => $value)
        {
            
$newParam->put($param$value);
        }
        
$newParam->put('SUBREPORT_DIR',$this->reportPath);
        
return $newParam;
    }

private function getReport($type='pdf',$params,$filename='report.jrmxl',$outputname='report&#039/;)/
    
{
try
        
{
            
$Conn = new Java("org.altic.jasperReports.JdbcConnection"); 
            
$Conn->setDriver("com.mysql.jdbc.Driver");
            
$Conn->setConnectString("jdbc:mysql://" $this->dbhost "/" $this->dbname);
            
$Conn->setUser($this->dbuser);
            
$Conn->setPassword($this->dbpass);
            
            
$arrayParam $this->getParam($params);
            
$compileManager = new JavaClass("net.sf.jasperreports.engine.JasperCompileManager");
            
$report $compileManager->compileReport($this->reportPath $filename);
            
            
$fillManager = new JavaClass("net.sf.jasperreports.engine.JasperFillManager");
            
$jasperPrint $fillManager->fillReport($report$arrayParam,$Conn->getConnection());
            
            
$outputPath =$this->reportPath $outputname . '.' . $type;
            
            
set_time_limit(120); 
 
            
java_set_file_encoding("ISO-8859-1"); 
             if (
$type == 'pdf&#039/;)/
             
{
                
$exporter = new java("net.sf.jasperreports.engine.export.JRPdfExporter"); 
                
$exParm java("net.sf.jasperreports.engine.JRExporterParameter"); 
                
$exporter->setParameter($exParm->JASPER_PRINT$jasperPrint); 
                
$exporter->setParameter($exParm->OUTPUT_STREAM$this->javaOutputStream); 
                
$exporter->exportReport(); 
         
                
header('Content-Type: application/pdf&#039/;)/; 
                
header('Content-Transfer-Encoding: binary&#039/;)/; 
                
header('Content-disposition: attachment; filename="'.$outputname.'.pdf"&#039/;)/; 
                
header('Pragma: no-cache&#039/;)/; 
                
header('Cache-Control: must-revalidate, post-check=0, pre-check=0&#039/;)/; 
                
header('Expires: 0&#039/;)/; 
         
                
echo java_cast($this->javaOutputStream->toByteArray(),"S"); 
        
             }
             elseif (
$type == 'xls&#039/;)/
             
{
             
$exporter = new java("net.sf.jasperreports.engine.export.JExcelApiExporter");
                
$exParm java("net.sf.jasperreports.engine.JRExporterParameter"); 
                
$exXlsParm java("net.sf.jasperreports.engine.export.JRXlsExporterParameter");
                
$exporter->setParameter($exParm->JASPER_PRINT$jasperPrint); 
                
$exporter->setParameter($exParm->OUTPUT_STREAM$this->javaOutputStream); 
                
$exporter->setParameter($exXlsParm->IS_ONE_PAGE_PER_SHEETfalse); //Continues, semua data di 1 worksheet
                
$exporter->setParameter($exXlsParm->IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWStrue); //Ilangin space diantara baris, biasana mengakibatkan row gak rapet2 di excel
                
$exporter->setParameter($exXlsParm->IS_REMOVE_EMPTY_SPACE_BETWEEN_COLUMNStrue); //Idem, tapi buat kolom
                
$exporter->setParameter($exXlsParm->IS_DETECT_CELL_TYPEtrue); //Otomatis detek type cell (numerik, string, etc)
                
$exporter->setParameter($exXlsParm->IS_WHITE_PAGE_BACKGROUNDfalse);
                
$exporter->exportReport(); 
         
                
header('Content-Type: application/xls&#039/;)/; 
                
header('Content-Transfer-Encoding: binary&#039/;)/; 
                
header('Content-disposition: attachment; filename="'.$outputname.'.xls"&#039/;)/; 
                
header('Pragma: no-cache&#039/;)/; 
                
header('Cache-Control: must-revalidate, post-check=0, pre-check=0&#039/;)/; 
                
header('Expires: 0&#039/;)/; 
 
        
echo java_cast($this->javaOutputStream->toByteArray(),"S"); 
         
}            
        }
        catch( 
JavaException $e)
        {
            echo 
$e;
        }    
}

public function cetakreportAction()
{
$this->_helper->viewRenderer->setNoRender(); //gak pake view

$type = 'pdf'; //output sebagai file PDF, kalo Excel tinggal ganti pake 'xls'

$params = array('param1' => 'parameter ke 1&#039/;)/; //parameter buat si report /:)/    

$this
->getReport($type,$params,'boq3.jrxml','boq3&#039/;)/; //boq3.jrxml adalah nama file jasper/ireport

}




untuk output excel menurut ane masih kurang bagus, soalna kalo kita design di iReport antar objek (textbox, label, etc) gak dirapet2in ntar ada row/kolom yg digabung/merge otomatis ma si jasper. Walopun kita dah pake option IS_REMOVE_EMPTY_SPACE_BETWEEN_COLUMNS n IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS pas compile report...

CMIIW emoticon-Smilieemoticon-Smilie
0