« | October 2025 | » | 日 | 一 | 二 | 三 | 四 | 五 | 六 | | | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | | |
| 公告 |
|
Blog信息 |
blog名称:KENWOOD 日志总数:8 评论数量:13 留言数量:0 访问次数:60013 建立时间:2006年7月31日 |

| |
JAVA 恶梦的开始 软件技术
Triger 发表于 2006/8/1 8:34:12 |
如何在Eclispe中用JAVA设用BIRT报表:---好东西共享(参考BIRT API 官方网站)
1:如下是全部代码
2:如果生成PDF,请将
options.setOutputFormat("html");
改成
options.setOutputFormat("PDF");
文件扩展名也要改为相应的PDF
3:加入com.ibm.icu_3.4.4.1.Jar \js.jar\coreapi.jar\engineapi.jar到
BUILD PATH 中
4:PDF记录有中文时出现乱码,请将itext-1.3放在
INSTALLDIR\birt-runtime-2_1_0
\ReportEngine\plugins\com.lowagie.itext\lib
5:本人用的是Eclispe 3.2,JDK1.4,BIRT2.1
package user;
import java.util.HashMap;
import java.util.logging.Level;
import org.eclipse.birt.core.framework.Platform;
import org.eclipse.birt.report.engine.api.EngineConfig;
import org.eclipse.birt.report.engine.api.EngineConstants;
import org.eclipse.birt.report.engine.api.EngineException;
import org.eclipse.birt.report.engine.api.HTMLActionHandler;
import org.eclipse.birt.report.engine.api.HTMLEmitterConfig;
import org.eclipse.birt.report.engine.api.HTMLRenderContext;
import org.eclipse.birt.report.engine.api.HTMLRenderOption;
import org.eclipse.birt.report.engine.api.HTMLServerImageHandler;
import org.eclipse.birt.report.engine.api.IReportEngine;
import org.eclipse.birt.report.engine.api.IReportEngineFactory;
import org.eclipse.birt.report.engine.api.IReportRunnable;
import org.eclipse.birt.report.engine.api.IRunAndRenderTask;
public class ExecuteReport {
static void executeReport() throws EngineException{
IReportEngine engine=null;
EngineConfig config = null;
try{
//Configure the Engine and start the Platform
config = new EngineConfig( );
config.setEngineHome( "C:/eclipse/workspace/ReportDrive/birt-runtime-2_1_0/ReportEngine" );
config.setLogConfig(null, Level.FINE);
Platform.startup( config );
IReportEngineFactory factory = (IReportEngineFactory) Platform
.createFactoryObject( IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY );
engine = factory.createReportEngine( config );
engine.changeLogLevel( Level.WARNING );
}catch( Exception ex){
ex.printStackTrace();
}
IReportRunnable design = null;
//Open the report design
design = engine.openReportDesign("C:/eclipse/workspace/html/ken.rptdesign");
IRunAndRenderTask task = engine.createRunAndRenderTask(design);
//Set rendering options - such as file or stream output,
//output format, whether it is embeddable, etc
HTMLRenderOption options = new HTMLRenderOption();
options.setOutputFileName("C:/eclipse/workspace/html/ken.htm");
//Set output format
options.setOutputFormat("html");
task.setRenderOption(options);
//run the report and destroy the engine
//Note - If the program stays resident do not shutdown the Platform or the Engine
task.run();
task.close();
engine.shutdown();
Platform.shutdown();
System.out.println("Finished");
System.exit(0);
}
public static void main(String[] args) {
try
{
executeReport( );
}
catch ( Exception e )
{
e.printStackTrace();
}
}
}
|
|
回复:JAVA 恶梦的开始 软件技术
runnnn(游客)发表评论于2006/9/4 12:17:17 |
|
» 1 »
|