使用Birt在HTML报表中创建标签

时间:2019-04-10 12:04:10

标签: java birt

我正在使用Birt(Engine Api)和一些Java代码创建一个报告。 现在,我不知道如何在单个报告中创建多个标签。 因此,每个标签在其中代表一个单独的表格。 有人可以帮我吗 我使用的以下代码

 IReportEngine config = new EngineConfig();
 config.setLogConfig("birtLogs", Level.WARNING);
 IRegistryProvider ireg =  RegistryProviderFactory.getDefault();
 org.eclipse.birt.core.framework.Platform.shutdown();             
 RegistryProviderFactory.releaseDefault();
 try {
    org.eclipse.birt.core.framework.Platform.startup(config);
 } catch (BirtException e1) {
        e1.printStackTrace();
 }
 IReportEngineFactory factory = (IReportEngineFactory)org.eclipse.birt.core.framework.Platform .createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);
engine = factory.createReportEngine(config);
URL rptFileUrl = null;
try {
 rptFileUrl = new URL("****/Reports/*****.rptdesign");
 } catch (MalformedURLException e1) {
  e1.printStackTrace();
 }
IReportRunnable reportRunnable = null;
  try {               
   if (rptFileUrl != null) {
reportRunnable =
engine.openReportDesign(rptFileUrl.openConnection().getInputStream());


  ReportDesignHandle designHandle = null;
designHandle = (ReportDesignHandle) reportRunnable.getDesignHandle();
 }         
} catch (EngineException | IOException e1) {
                   e1.printStackTrace();
}
while (designHandle.getBody().getCount() > 0) {                
 try {
     designHandle.getBody().dropAndClear(0);
  } catch (SemanticException e) {
      e.printStackTrace();
  }
}
  ElementFactory designFactory = designHandle.getElementFactory();
  try {
   designHandle.setProperty("title", "Description");
   /* creating Grid for the Tab */
   createGrid(designHandle,designFactory);

   /*createTab(designHandle,designFactory);*/ // I have to Implement for the Tab.


  } catch (SemanticException e1) {
    e1.printStackTrace();
  }


 engine.destroy();
  designHandle.getBody().getContents().clear();
  designHandle.close();

 org.eclipse.birt.core.framework.Platform.shutdown();
             try { 
               RegistryProviderFactory.setDefault(ireg);
             } catch (CoreException e) {
               e.printStackTrace();
             }


         }
            } ) ;
          } catch (InvocationTargetException | InterruptedException e) {
            e.printStackTrace();
          }


我使用了designFactory,designHandle(上面的代码)来创建Grid并在其中插入数据。我期望designFactory,designHandle也将帮助创建多个选项卡,但我不知道该怎么做。请帮我一些代码。

0 个答案:

没有答案