Esempio n. 1
0
 public function runReportToOdtFile($inputFileName, $outputFileName, $parameters, $conn)
 {
     if (!isset($conn)) {
         $conn = $this->getJdbcConnection();
     }
     if (!$outputFileName) {
         $outputFileName = dirname($inputFileName) . '/' . pathinfo($inputFileName, PATHINFO_FILENAME) . '.odt';
     }
     try {
         $JasperFillManager = new Java('net.sf.jasperreports.engine.JasperFillManager');
         $fillReport = $JasperFillManager->fillReport($inputFileName, $parameters, $conn);
         $JROdtExporter = new Java('net.sf.jasperreports.engine.export.oasis.JROdtExporter');
         $JRExporterParameter = new Java('net.sf.jasperreports.engine.JRExporterParameter');
         $JROdtExporter->setParameter($JRExporterParameter->JASPER_PRINT, $fillReport);
         $JROdtExporter->setParameter($JRExporterParameter->OUTPUT_FILE_NAME, $outputFileName);
         $JROdtExporter->exportReport();
         return true;
     } catch (JavaException $ex) {
         $trace = new Java('java.io.ByteArrayOutputStream');
         $ex->printStackTrace(new Java('java.io.PrintStream', $trace));
         print nl2br("java stack trace: {$trace}\n");
         return false;
     }
 }