コード例 #1
0
ファイル: wellTestReport.blade.php プロジェクト: hunglmtb/eb
            java_set_file_encoding("ISO-8859-1");
            $contentType = "application/pdf";
            // export Pdf
            $out = $root . "/output.pdf";
            java("net.sf.jasperreports.engine.JasperExportManager")->exportReportToPdfFile($print, $out);
        } elseif ($exportType == "HTML") {
            // export Pdf
            $out = $root . "/output.Html";
            $contentType = "text/Html";
            java("net.sf.jasperreports.engine.JasperExportManager")->exportReportToHtmlFile($print, $out);
        } elseif ($exportType == "Excel") {
            $out = $root . "/output.xls";
            $contentType = "application/vnd.ms-excel";
            $xlsExporter = new java("net.sf.jasperreports.engine.export.JRXlsExporter");
            $JRXlsExporterParameter = java("net.sf.jasperreports.engine.export.JRXlsExporterParameter");
            $xlsExporter->setParameter($JRXlsExporterParameter->JASPER_PRINT, $print);
            $xlsExporter->setParameter($JRXlsExporterParameter->OUTPUT_FILE, new java("java.io.File", $out));
            $xlsExporter->setParameter($JRXlsExporterParameter->IS_DETECT_CELL_TYPE, true);
            $xlsExporter->setParameter($JRXlsExporterParameter->IS_IGNORE_GRAPHICS, true);
            // $xlsExporter->setParameter($JRXlsExporterParameter->IS_WHITE_PAGE_BACKGROUND, true);
            $xlsExporter->exportReport();
        }
        header("Content-type: " . $contentType);
        readfile($out);
        // unlink($out);
    } catch (Exception $ex) {
        echo "<b>Error...:</b>" . $ex->getCause();
    }
    echo "done";
}
?>
コード例 #2
0
ファイル: summaryCPReportExcel.php プロジェクト: hunglmtb/eb
            java_set_file_encoding("ISO-8859-1");
            $contentType = "application/pdf";
            // export Pdf
            $out = $root . "/output.pdf";
            java("net.sf.jasperreports.engine.JasperExportManager")->exportReportToPdfFile($print, $out);
        } elseif ($exportType == "HTML") {
            // export Pdf
            $out = $root . "/output.Html";
            $contentType = "text/Html";
            java("net.sf.jasperreports.engine.JasperExportManager")->exportReportToHtmlFile($print, $out);
        } elseif ($exportType == "Excel") {
            $out = $root . "/output.xls";
            $contentType = "application/vnd.ms-excel";
            $xlsExporter = new java("net.sf.jasperreports.engine.export.JRXlsExporter");
            $JRXlsExporterParameter = java("net.sf.jasperreports.engine.export.JRXlsExporterParameter");
            $xlsExporter->setParameter($JRXlsExporterParameter->JASPER_PRINT, $print);
            $xlsExporter->setParameter($JRXlsExporterParameter->OUTPUT_FILE, new java("java.io.File", $out));
            //$xlsExporter->setParameter($JRXlsExporterParameter->IS_WHITE_PAGE_BACKGROUND, true);
            $xlsExporter->exportReport();
        }
        header("Content-type: " . $contentType);
        readfile($out);
        //unlink($out);
    } catch (Exception $ex) {
        echo "<b>Error...:</b>" . $ex->getCause();
    }
    echo "done";
}
?>

コード例 #3
0
ファイル: Jreport.php プロジェクト: backstageel/JasperPHP
 function export($typeoffile)
 {
     $jasperPrint = $this->jasperPrint;
     $exporter = new \java("net.sf.jasperreports.engine.JRExporter");
     set_time_limit(0);
     switch ($typeoffile) {
         case 'xls':
             $outputPath = tempnam(realpath("tmp"), $this->filename);
             //generate unique temp file name
             chmod($outputPath, 0766);
             //allow tomcat to write permission
             try {
                 $exporter = new \java("net.sf.jasperreports.engine.export.JRXlsExporter");
                 $exporter->setParameter(\java("net.sf.jasperreports.engine.export.JRXlsExporterParameter")->IS_ONE_PAGE_PER_SHEET, java("java.lang.Boolean")->FALSE);
                 $exporter->setParameter(\java("net.sf.jasperreports.engine.export.JRXlsExporterParameter")->IS_WHITE_PAGE_BACKGROUND, java("java.lang.Boolean")->FALSE);
                 $exporter->setParameter(\java("net.sf.jasperreports.engine.export.JRXlsExporterParameter")->IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, java("java.lang.Boolean")->TRUE);
                 $exporter->setParameter(\java("net.sf.jasperreports.engine.export.JRXlsExporterParameter")->IS_DETECT_CELL_TYPE, java("java.lang.Boolean")->TRUE);
                 $exporter->setParameter(\java("net.sf.jasperreports.engine.JRExporterParameter")->JASPER_PRINT, $jasperPrint);
                 $exporter->setParameter(\java("net.sf.jasperreports.engine.JRExporterParameter")->OUTPUT_FILE_NAME, $outputPath);
             } catch (\JavaException $ex) {
                 echo $ex;
             }
             header("Content-type: application/vnd.ms-excel;");
             header("Content-Disposition: attachment; filename={$this->filename}.xls");
             break;
         case 'csv':
             $outputPath = tempnam(realpath("tmp"), $this->filename);
             //generate unique temp file name
             chmod($outputPath, 0766);
             try {
                 $exporter = new \java("net.sf.jasperreports.engine.export.JRCsvExporter");
                 $exporter->setParameter(\java("net.sf.jasperreports.engine.export.JRCsvExporterParameter")->FIELD_DELIMITER, ",");
                 $exporter->setParameter(\java("net.sf.jasperreports.engine.export.JRCsvExporterParameter")->RECORD_DELIMITER, "\n");
                 $exporter->setParameter(\java("net.sf.jasperreports.engine.export.JRCsvExporterParameter")->CHARACTER_ENCODING, "UTF-8");
                 $exporter->setParameter(\java("net.sf.jasperreports.engine.JRExporterParameter")->JASPER_PRINT, $jasperPrint);
                 $exporter->setParameter(\java("net.sf.jasperreports.engine.JRExporterParameter")->OUTPUT_FILE_NAME, $outputPath);
             } catch (\JavaException $ex) {
                 echo $ex;
             }
             header("Content-type: application/csv");
             header("Content-Disposition: attachment; filename={$this->filename}.csv");
             break;
         case 'docx':
             $outputPath = tempnam(realpath("tmp"), $this->filename);
             //generate unique temp file name
             chmod($outputPath, 0766);
             try {
                 $exporter = new \java("net.sf.jasperreports.engine.export.ooxml.JRDocxExporter");
                 $exporter->setParameter(\java("net.sf.jasperreports.engine.JRExporterParameter")->JASPER_PRINT, $jasperPrint);
                 $exporter->setParameter(\java("net.sf.jasperreports.engine.JRExporterParameter")->OUTPUT_FILE_NAME, $outputPath);
             } catch (\JavaException $ex) {
                 echo $ex;
             }
             header("Content-type: application/vnd.ms-word");
             header("Content-Disposition: attachment; filename={$this->filename}.docx");
             break;
         case 'html':
             $outputPath = tempnam(realpath("tmp"), $this->filename);
             //generate unique temp file name
             chmod($outputPath, 0766);
             try {
                 $exporter = new \java("net.sf.jasperreports.engine.export.JRHtmlExporter");
                 $exporter->setParameter(\java("net.sf.jasperreports.engine.JRExporterParameter")->JASPER_PRINT, $jasperPrint);
                 $exporter->setParameter(\java("net.sf.jasperreports.engine.JRExporterParameter")->OUTPUT_FILE_NAME, $outputPath);
             } catch (\JavaException $ex) {
                 echo $ex;
             }
             break;
         case 'pdf':
             $outputPath = tempnam(realpath("tmp"), $this->filename);
             //generate unique temp file name
             chmod($outputPath, 0766);
             try {
                 $exporter = new \java("net.sf.jasperreports.engine.export.JRPdfExporter");
                 $exporter->setParameter(\java("net.sf.jasperreports.engine.JRExporterParameter")->JASPER_PRINT, $jasperPrint);
                 $exporter->setParameter(\java("net.sf.jasperreports.engine.JRExporterParameter")->OUTPUT_FILE_NAME, $outputPath);
             } catch (\JavaException $ex) {
                 echo $ex;
             }
             header("Content-type: application/pdf");
             header("Content-Disposition: inline; filename={$this->filename}.pdf");
             header("Cache-Control: no-cache, must-revalidate");
             // HTTP/1.1
             header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT', true, 200);
             header("Expires: -1");
             break;
         case 'ods':
             $outputPath = tempnam(realpath("tmp"), $this->filename);
             //generate unique temp file name
             chmod($outputPath, 0766);
             try {
                 $exporter = new \java("net.sf.jasperreports.engine.export.oasis.JROdsExporter");
                 $exporter->setParameter(\java("net.sf.jasperreports.engine.JRExporterParameter")->JASPER_PRINT, $jasperPrint);
                 $exporter->setParameter(\java("net.sf.jasperreports.engine.JRExporterParameter")->OUTPUT_FILE_NAME, $outputPath);
             } catch (\JavaException $ex) {
                 echo $ex;
             }
             header("Content-type: application/vnd.oasis.opendocument.spreadsheet");
             header("Content-Disposition: attachment; filename={$this->filename}.ods");
             break;
         case 'odt':
             $outputPath = tempnam(realpath("tmp"), $this->filename);
             //generate unique temp file name
             chmod($outputPath, 0766);
             try {
                 $exporter = new \java("net.sf.jasperreports.engine.export.oasis.JROdtExporter");
                 $exporter->setParameter(\java("net.sf.jasperreports.engine.JRExporterParameter")->JASPER_PRINT, $jasperPrint);
                 $exporter->setParameter(\java("net.sf.jasperreports.engine.JRExporterParameter")->OUTPUT_FILE_NAME, $outputPath);
             } catch (\JavaException $ex) {
                 echo $ex;
             }
             header("Content-type: application/vnd.oasis.opendocument.text");
             header("Content-Disposition: attachment; filename={$this->filename}.odt");
             break;
         case 'txt':
             $outputPath = tempnam(realpath("tmp"), $this->filename);
             //generate unique temp file name
             chmod($outputPath, 0766);
             try {
                 $exporter = new \java("net.sf.jasperreports.engine.export.JRTextExporter");
                 $exporter->setParameter(\java("net.sf.jasperreports.engine.export.JRTextExporterParameter")->PAGE_WIDTH, 120);
                 $exporter->setParameter(\java("net.sf.jasperreports.engine.export.JRTextExporterParameter")->PAGE_HEIGHT, 60);
                 $exporter->setParameter(\java("net.sf.jasperreports.engine.JRExporterParameter")->JASPER_PRINT, $jasperPrint);
                 $exporter->setParameter(\java("net.sf.jasperreports.engine.JRExporterParameter")->OUTPUT_FILE_NAME, $outputPath);
             } catch (\JavaException $ex) {
                 echo $ex;
             }
             header("Content-type: text/plain");
             break;
         case 'rtf':
             $outputPath = tempnam(realpath("tmp"), $this->filename);
             //generate unique temp file name
             chmod($outputPath, 0766);
             try {
                 $exporter = new \java("net.sf.jasperreports.engine.export.JRRtfExporter");
                 $exporter->setParameter(\java("net.sf.jasperreports.engine.JRExporterParameter")->JASPER_PRINT, $jasperPrint);
                 $exporter->setParameter(\java("net.sf.jasperreports.engine.JRExporterParameter")->OUTPUT_FILE_NAME, $outputPath);
             } catch (\JavaException $ex) {
                 echo $ex;
             }
             header("Content-type: application/rtf");
             header("Content-Disposition: attachment; filename={$this->filename}.rtf");
             break;
         case 'pptx':
             $outputPath = tempnam(realpath("tmp"), $this->filename);
             //generate unique temp file name
             chmod($outputPath, 0766);
             try {
                 $exporter = new \java("net.sf.jasperreports.engine.export.ooxml.JRPptxExporter");
                 $exporter->setParameter(\java("net.sf.jasperreports.engine.JRExporterParameter")->JASPER_PRINT, $jasperPrint);
                 $exporter->setParameter(\java("net.sf.jasperreports.engine.JRExporterParameter")->OUTPUT_FILE_NAME, $outputPath);
             } catch (\JavaException $ex) {
                 echo $ex;
             }
             header("Content-type: application/vnd.ms-powerpoint");
             header("Content-Disposition: attachment; filename={$this->filename}.pptx");
             break;
             /* 	It exists
                           case 'swf':
                           $outputPath = tempnam(realpath("tmp"), $this->filename);  //generate unique temp file name    
             
                           try {
                           $exporter = new \java("net.sf.jasperreports.engine.export.JRXml4SwfExporter");
                           $exporter->setParameter(\java("net.sf.jasperreports.engine.JRExporterParameter")->JASPER_PRINT, $jasperPrint);
                           $exporter->setParameter(\java("net.sf.jasperreports.engine.JRExporterParameter")->OUTPUT_FILE_NAME, $outputPath);
                           } catch (\JavaException $ex) {
                           echo $ex;
                           }
             
                           header("Content-type: application/swf");
                           header("Content-Disposition: attachment; filename={$this->filename}.swf");
                           $exporter->exportReport();
                           break;
                          */
     }
     $exporter->exportReport();
     readfile($outputPath);
     unlink($outputPath);
 }
コード例 #4
0
 function reporte($id = null)
 {
     require_once "http://localhost:8080/JavaBridge/java/Java.inc";
     $parteId = $id;
     $params = new Java("java.util.HashMap");
     $params->put("parteid", $parteId);
     try {
         $jasperxml = new java("net.sf.jasperreports.engine.xml.JRXmlLoader");
         $jasperDesign = $jasperxml->load(realpath("InformedePartes.jrxml"));
         $query = new java("net.sf.jasperreports.engine.design.JRDesignQuery");
         $query->setText("select u.username, p.* ,t.inicial as tinicial, t.final as tfinal, t.entrada as tentrada, t.salida as tsalida,\n\t\t\t\t\t\t\tr.inicial as rinicial, r.final as rfinal, r.entrada as rentrada, r.salida as rsalida,\n\t\t\t\t\t\t\te.inicial as einicial, e.final as efinal,\n\t\t\t\t\t\t\te2.entrada as eeentrada, e2.salida as eesalida, e2.inicial as eeinicial, e2.final as eefinal\n\t\t\t\t\t\tfrom partes p , textos t ,reales r , enteros e,  enteros e2, users u\n\t\t\t\t\t\twhere  p.id=t.parte_id and p.id=r.parte_id and p.id=e.parte_id and p.id=e2.parte_id and p.id={$parteId}\n\t\t\t\t\t\tand e.tipocampos_tipoparte_id=2 and e2.tipocampos_tipoparte_id=6 and u.id=p.usuariovendedor;");
         $jasperDesign->setQuery($query);
         $compileManager = new JavaClass("net.sf.jasperreports.engine.JasperCompileManager");
         $report = $compileManager->compileReport($jasperDesign);
     } catch (JavaException $ex) {
         echo $ex;
     }
     $fillManager = new JavaClass("net.sf.jasperreports.engine.JasperFillManager");
     $class = new JavaClass("java.lang.Class");
     $class->forName("com.mysql.jdbc.Driver");
     $driverManager = new JavaClass("java.sql.DriverManager");
     //db username and password
     $conn = $driverManager->getConnection("jdbc:mysql://localhost:3306/estacion?zeroDateTimeBehavior=convertToNull", "root", "");
     $jasperPrint = $fillManager->fillReport($report, $params, $conn);
     $exporter = new java("net.sf.jasperreports.engine.JRExporter");
     $outputPath = realpath(".") . "\\" . "InformedePartes.pdf";
     $exporter = new java("net.sf.jasperreports.engine.export.JRPdfExporter");
     $exporter->setParameter(java("net.sf.jasperreports.engine.JRExporterParameter")->JASPER_PRINT, $jasperPrint);
     $exporter->setParameter(java("net.sf.jasperreports.engine.JRExporterParameter")->OUTPUT_FILE_NAME, $outputPath);
     header("Content-type: application/pdf");
     header("Content-Disposition: attachment; filename=InformedePartes.pdf");
     $exporter->exportReport();
     readfile($outputPath);
     unlink($outputPath);
 }
コード例 #5
0
 function reporte()
 {
     require_once "http://localhost:8080/JavaBridge/java/Java.inc";
     try {
         $jasperxml = new java("net.sf.jasperreports.engine.xml.JRXmlLoader");
         $jasperDesign = $jasperxml->load(realpath("InformedeUsuarios.jrxml"));
         $query = new java("net.sf.jasperreports.engine.design.JRDesignQuery");
         $query->setText("select users.*, roles.name\n\t\t\t\t\tfrom users INNER JOIN roles ON users.role_id=roles.id");
         $jasperDesign->setQuery($query);
         $compileManager = new JavaClass("net.sf.jasperreports.engine.JasperCompileManager");
         $report = $compileManager->compileReport($jasperDesign);
     } catch (JavaException $ex) {
         echo $ex;
     }
     $fillManager = new JavaClass("net.sf.jasperreports.engine.JasperFillManager");
     $params = new Java("java.util.HashMap");
     $params->put("title", "Customer");
     $class = new JavaClass("java.lang.Class");
     $class->forName("com.mysql.jdbc.Driver");
     $driverManager = new JavaClass("java.sql.DriverManager");
     //db username and password
     $conn = $driverManager->getConnection("jdbc:mysql://localhost:3306/estacion?zeroDateTimeBehavior=convertToNull", "root", "");
     $jasperPrint = $fillManager->fillReport($report, $params, $conn);
     $exporter = new java("net.sf.jasperreports.engine.JRExporter");
     $outputPath = realpath(".") . "\\" . "InformedeUsuarios.pdf";
     $exporter = new java("net.sf.jasperreports.engine.export.JRPdfExporter");
     $exporter->setParameter(java("net.sf.jasperreports.engine.JRExporterParameter")->JASPER_PRINT, $jasperPrint);
     $exporter->setParameter(java("net.sf.jasperreports.engine.JRExporterParameter")->OUTPUT_FILE_NAME, $outputPath);
     header("Content-type: application/pdf");
     header("Content-Disposition: attachment; filename=InformedeUsuarios.pdf");
     $exporter->exportReport();
     readfile($outputPath);
     unlink($outputPath);
 }