`
wwwxxx286
  • 浏览: 50383 次
  • 性别: Icon_minigender_1
  • 来自: 苏州
社区版块
存档分类
最新评论

I-Net Clear Report Engine

 
阅读更多
I-Net Clear Report Engine is an excellent tool which also can support standard HTML/CSS well. You can define rpt template by clear designer, and can create datasource to query result from database, pass parameter by java......

import java.io.FileOutputStream;

import com.inet.report.Datasource;
import com.inet.report.Engine;

/**
 * @Class name:	IClearTest.java
 *
 * Short description on the purpose of the program.
 *
 * @author:		wangxiang
 * @modified:	2011-11-30
 *
 */

public class IClearTest {

	private static boolean useStdout=false;
    private static String reportFile = "file:D:/Report4.rpt";
	/**
	 * @param args
	 */
    static void usage () {
    	System.err.println("Usage: ProgrammingTheEngine [--use-stdout]");
    	System.exit(1);
    }

    /**
     * Checks if parameter values has been set.
     * @param args first parameter is stdout, second parameter is report file URL
     */
    static void getOpt (String[] args) {
		for (int i = 0; i< args.length; i++) {
		    if (args[i].equals("--use-stdout")) {
		    	useStdout = true;
		    	System.err.println("writing PDF file to stdout");
		    }
		    else if (args[i].equals("--report")) {
		    	reportFile = args[++i];
		    } else {
		    	usage();
		    }
		}
    }
    
    /**
     * Executes a report and exports it to PDF.
     * @param args first parameter is stdout, second parameter is report file URL
     */
    public static void main(String[] args) {
    	getOpt(args);

        try {
        	// Create an engine -> pdf export
            Engine engine = new Engine(Engine.EXPORT_PDF);

    	    // Set the report file
            engine.setReportFile(reportFile);

		    // At this point you can change the default values from the rpt file, e.g.:
            // Change Data Source Configuration - Use another database at runtime as at design time
            Datasource ds = engine.getDatabaseTables().getDatasource(0);    
            ds.setDataSourceConfigurationName( "ORCL" );  // name of the Data Source Configuration 
            ds.setUsername("userid");                  // that should be used for creation of database connection
            ds.setPassword("password");  // If the password is not saved in Data Source Configuration
            
            // Set Parameter Field values
            engine.setPrompt("htmlContent", "<table><tr><td>test</td></tr></table>");

            // Start the report execution
            engine.execute();

            // Open the output file and save the data in a .pdf file or in standard out
            java.io.OutputStream pdfFile;
            if(useStdout) {
                pdfFile = System.out; 
            } else {
                pdfFile = new FileOutputStream("D:/cleartest.pdf");
            }

            // Request all report pages from the engine
			for(int i=1;i<=engine.getPageCount();i++) {
				pdfFile.write(engine.getPageData(i));
			}
      	    if(useStdout) {
      	        pdfFile.flush(); 
      	    } else {
      	        pdfFile.close();
      	    }
        } catch (Throwable t ) { 
            t.printStackTrace();
        }
        System.exit(0);
    }

}

0
1
分享到:
评论

相关推荐

    FastReport.v4.15 for.Delphi.BCB.Full.Source企业版含ClientServer中文修正版支持D4-XE5

    + added support of /PAGE tag in TfrxRichView, engine automatically break report pages when find /PAGE tag + added ability to hide Null values in TfrxChartView (TfrxChartView.IgnoreNulls = True) + ...

    三星K2200维修手册

    - **Report(报告)**:提供机器的工作状态报告,有助于诊断问题。 - **Configuration(配置)**:用于查看和修改复印机的配置设置,如网络设置等。 - **Supplies Information(耗材信息)**:显示耗材的使用情况,...

    CE中文版-启点CE过NP中文.exe

    启点CE过NP中文December 24 2018:Cheat Engine 6.8.2 Released: Here's a new version for the hollidays. Mainly minor improvements and some small bugfixes, but also a new 'ultimap like' feature called ...

    c# .net 水晶报表使用集

    report.ParameterFields["YourParameterName"].CurrentValues.Clear(); report.ParameterFields["YourParameterName"].CurrentValues.Add("ParameterValue"); ``` 此外,水晶报表支持导出报表为多种格式,如PDF、...

    myBase Desktop 6.3.3 12/1/2013 绿色 完美破解版

    Added: the 64-bit structured storage engine (SSG-5), which enables you to create large database files (&gt;2GiB), and encrypt data on the fly using AES-256 while saving information into your database. ...

    Dreamweaver CS4 黄金插件10-1

    22. Clear Initial Form Fields V2.1.1 For Adobe Dreamweaver 23. Close All Documents V1.0.5 For Adobe Dreamweaver 24. Close Bowser Window V1.2.0 For Adobe Dreamweaver 25. Close Button 1.1.1 For Adobe ...

    Dreamweaver CS4 黄金插件10-02

    22. Clear Initial Form Fields V2.1.1 For Adobe Dreamweaver 23. Close All Documents V1.0.5 For Adobe Dreamweaver 24. Close Bowser Window V1.2.0 For Adobe Dreamweaver 25. Close Button 1.1.1 For Adobe ...

    Dreamweaver CS4 黄金插件10-05

    22. Clear Initial Form Fields V2.1.1 For Adobe Dreamweaver 23. Close All Documents V1.0.5 For Adobe Dreamweaver 24. Close Bowser Window V1.2.0 For Adobe Dreamweaver 25. Close Button 1.1.1 For Adobe ...

    Dreamweaver CS4 黄金插件10-03

    22. Clear Initial Form Fields V2.1.1 For Adobe Dreamweaver 23. Close All Documents V1.0.5 For Adobe Dreamweaver 24. Close Bowser Window V1.2.0 For Adobe Dreamweaver 25. Close Button 1.1.1 For Adobe ...

    Dreamweaver CS4 黄金插件10-04

    22. Clear Initial Form Fields V2.1.1 For Adobe Dreamweaver 23. Close All Documents V1.0.5 For Adobe Dreamweaver 24. Close Bowser Window V1.2.0 For Adobe Dreamweaver 25. Close Button 1.1.1 For Adobe ...

    Dreamweaver CS4 黄金插件10-08

    22. Clear Initial Form Fields V2.1.1 For Adobe Dreamweaver 23. Close All Documents V1.0.5 For Adobe Dreamweaver 24. Close Bowser Window V1.2.0 For Adobe Dreamweaver 25. Close Button 1.1.1 For Adobe ...

    Dreamweaver CS4 黄金插件10-06

    22. Clear Initial Form Fields V2.1.1 For Adobe Dreamweaver 23. Close All Documents V1.0.5 For Adobe Dreamweaver 24. Close Bowser Window V1.2.0 For Adobe Dreamweaver 25. Close Button 1.1.1 For Adobe ...

    Dreamweaver CS4 黄金插件10-07

    22. Clear Initial Form Fields V2.1.1 For Adobe Dreamweaver 23. Close All Documents V1.0.5 For Adobe Dreamweaver 24. Close Bowser Window V1.2.0 For Adobe Dreamweaver 25. Close Button 1.1.1 For Adobe ...

Global site tag (gtag.js) - Google Analytics