B4J Question [ABMaterial] Reports engine export.

jahswant

Well-Known Member
Licensed User
Longtime User
Hi all. I know it's not too related to ABMaterial but I'm porting a windows app to webapp.I've many crystal reports in this app. I'll like to export them as for next reports or jasper reports i don't if it's possible. I fount this code the internet.
B4X:
/Export Crystal Reports to pdf in java
public static void main() {
    try {
        //Overwrite any existing properties with updated values.
        //information Oracle database
        String DBUSERNAME = "user1";
        String DBPASSWORD = "user123456";
        String SERVERNAME = "112.123.1.1123";
        String PORT = "1521";
        String DATABASE_NAME = "ORCL"; // SID or Instance
        String URI = "!oracle.jdbc.driver.OracleDriver!jdbc:oracle:thin:{userid}/{password}@" + SERVERNAME + ":" + PORT + "/" + DATABASE_NAME;  //1521/ or :1521
        String DATABASE_DLL = "crdb_jdbc.dll";
        //end
       
        String report_name = "D:\\report\\oracle_demo_3.rpt";
        String exportFileName = "D:\\report\\oracle_demo_3.pdf";
        ReportClientDocument clientDoc = new ReportClientDocument();
        clientDoc.open(report_name, ReportExportFormat._PDF);
 
        // Obtain collection of tables from this database controller.
        ITable table = clientDoc.getDatabaseController().getDatabase().getTables().getTable(0);
 
        IConnectionInfo connectionInfo = table.getConnectionInfo();
        PropertyBag propertyBag = connectionInfo.getAttributes();
        propertyBag.clear();
 
        //Overwrite any existing properties with updated values.
        propertyBag.put("Trusted_Connection", "false");
        propertyBag.put("Server Name", SERVERNAME); //Optional property.
        propertyBag.put("Database Name", DATABASE_NAME);
        propertyBag.put("Server Type", "JDBC (JNDI)");
        propertyBag.put("URI", URI);
        propertyBag.put("Use JDBC", "true");
        propertyBag.put("Database DLL", DATABASE_DLL);
        connectionInfo.setAttributes(propertyBag);
 
        //Set database username and password.
        //NOTE: Even if these the username and password properties don't change when switching databases, the
        //database password is *not* saved in the report and must be set at runtime if the database is secured.
        connectionInfo.setUserName(DBUSERNAME);
        connectionInfo.setPassword(DBPASSWORD);
        connectionInfo.setKind(ConnectionInfoKind.SQL);
 
        table.setConnectionInfo(connectionInfo);
        //Update old table in the report with the new table.
        clientDoc.getDatabaseController().setTableLocation(table, table);
 
        clientDoc.getDataDefController().getParameterFieldController().setCurrentValue("", "p_id", 14);
        //Writing into PDF file
        ByteArrayInputStream bais = (ByteArrayInputStream) clientDoc.getPrintOutputController().export(ReportExportFormat.PDF);
        int size = bais.available();
        byte[] barray = new byte[size];
        FileOutputStream fos = new FileOutputStream(new File(exportFileName));
        ByteArrayOutputStream baos = new ByteArrayOutputStream(size);
        int bytes = bais.read(barray, 0, size);
        baos.write(barray, 0, bytes);
        baos.writeTo(fos);
        clientDoc.close();
        bais.close();
        baos.close();
        fos.close();
        //dbConn.close();
 
    } catch (ReportSDKException ex) {
        System.out.println("ReportSDKException" + ex);
    } catch (Exception ex) {
        System.out.println("Exception" + ex);
    }
}
From this link . I don't want to rewrite these reports.
Any thoughts about a wrapper ?
 

Harris

Expert
Licensed User
Longtime User
You may make some headway by asking the communities at Jasper or NextReports if they have any tools for converting Crystal to their formats...

Try NR for yourself. It does a really good job for light weight reporting - and it is free.
What I have learned from all reporting systems is that you are better off pre-processing your report data into temp tables - then let the report engine output your results.
 
Upvote 0
Top