【问题标题】:Accessing the contents of Detail section in BIRT report访问 BIRT 报告中详细信息部分的内容
【发布时间】:2013-05-31 13:42:45
【问题描述】:

我正在使用 BIRT 报告,以 xml 格式生成它,我正在编写发射器(BIRT 插件)。我需要一个 xml 报告,其中包含基于同一报告中某些部分的一些重复部分。我为此使用 subReports。所以报告结构就像


List--
  Header--
    Table---(No header and footer)
       details--- 
          Cell----
             Text(Multiple text here) Some static section and dynamic data
List Details ----
   Table--(No header and footer)(This table will be repeated for every record in the header part)
      Details--
          Cell --
             Multiple Text elements ()`
List Footer---- Empty

在编写发射器时,我主要需要提取 Cell 元素中的所有文本元素的内容。下面是我的发射器中 sartCell 方法的代码。

    public void startCell(ICellContent arg0) {
    System.out.println("text in Cell:: ");
    System.out.println("text in Cell:: " + arg0.getInstanceID());

    for(Object ie : arg0.getChildren())
    {
        if(ie instanceof  LabelContent)
        {
            LabelContent lc = (LabelContent)ie;
            stringBuilder.append(lc.getText());
            System.out.println(lc.getText());
        }
        else if(ie instanceof ForeignContent)
        {
            ForeignContent fc = (ForeignContent)ie;
            stringBuilder.append(fc.getRawValue());
            System.out.println(fc.getRawValue());
        }

    }

}

我可以使用此逻辑访问单元格及其所有文本内容。但是我想对 List 的 Details 部分中的 Table 的所有单元格做同样的事情。 问题是细节部分的单元格在 ICellContent.getChildren() 上给出了 null。

是的,我的 startText 方法根本没有被调用。以下是我的emmiter的声明,

公共类 XmlEmittor 扩展 ContentEmitterAdapter {...}

下面是rptDesign结构,

<List>
    <Header>
           <Table><Detail><Cell><Text>...DynamicText....</Text>.....</Table>
    </Header>
    <Detail>
           <Table><Detail><Cell><Text>...DynamicText....</Text>.....</Table>
    </Detail>
</List>

在上面的结构中,我的文本元素本身具有我想要生成报告的 XML 结构。所以我只想附加我的 xml 的所有内容并将其写入输出流。请建议,提前谢谢

【问题讨论】:

    标签: birt


    【解决方案1】:

    如果是 Text 元素,

    public void startText(ITextContent text) 
    

    public void startData(IDataContent data) throws BirtException
    

    将被调用,但在 Dynamic Text 元素的情况下

    public void startForeign(IForeignContent foreign) throws BirtException
    

    将被调用。

    你可以使用下面的代码sn-p来获取动态文本值

    @Override
    public void startForeign(IForeignContent foreign) throws BirtException {        
        Object rawValue = foreign.getRawValue();    
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多