Jump to content
Changes to the Jaspersoft community edition download ×

Recommended Posts

By: Wesley Ng - abrabra

Subreports

2003-03-19 00:03

Hi, if I want to create multiple subreports, can I do something like this:

 

fill:

JasperReport subreport1 = (JasperReport)JRLoader.loadObject("Report1.jasper");

 

JasperReport subreport2 = (JasperReport)JRLoader.loadObject("Report2.jasper");

//Preparing parameters

Map parameters = new HashMap();

parameters.put("Subreport1", subreport1);

parameters.put("Subreport2", subreport2);

//DataSource for subreports

parameters.put("Data1", new tempTableModel1());

parameters.put("Data2", new tempTableModel2());

 

JasperFillManager.fillReportToFile(fileName, parameters, new MasterTableModel());

 

And how can I make Subreport 1 and 2 get the data source from Data 1 and 2?

 

Regards,

 

 

 

 

By: Giulio Toffoli - gt78

RE: Subreports

2003-03-19 01:16

You must use subreport connection expression in the subreport element located in the master report.

 

Giulio

 

 

 

 

By: Teodor Danciu - teodord

RE: Subreports

2003-03-19 02:12

 

Hi,

 

You use the <dataSourceExpression> tag,

not the <connectionExpression> tag to pass

the data source parameter to the corresponding

subreport.

 

I hope this helps.

Teodor

 

 

 

 

 

By: Wesley Ng - abrabra

RE: Subreports

2003-03-19 02:30

In the program I do something like:

parameters.put("DS", new JRTableModelDataSource(new DS2()));

JasperFillManager.fillReportToFile(fileName1, parameters, new JRTableModelDataSource(new DS1()));

 

And in the Main.xml:

<parameter name="DS" isForPrompting="true" class="dori.jasper.engine.JRDataSource"/>

.

.

.

.

<subreport isUsingCache="true">

<reportElement

mode="Opaque"

x="10"

y="95"

width="516"

height="200"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<dataSourceExpression>$P{DS}</dataSourceExpression>

<subreportExpression class="java.lang.String"><![CDATA["SubReport.jasper"]]></subreportExpression>

</subreport>

 

Is this the correct way? Because I keep getting this error:

[java] dori.jasper.engine.JRException: Error loading object from file : C:

jasperJasperReportsdemosamplestestMain.xml

 

 

 

 

By: Wesley Ng - abrabra

RE: Subreports

2003-03-19 02:36

In the program I do something like:

parameters.put("DS", new JRTableModelDataSource(new DS2()));

JasperFillManager.fillReportToFile(fileName1, parameters, new JRTableModelDataSource(new DS1()));

 

And in the Main.xml:

<parameter name="DS" isForPrompting="true" class="dori.jasper.engine.JRDataSource"/>

.

.

.

.

<subreport isUsingCache="true">

<reportElement

mode="Opaque"

x="10"

y="95"

width="516"

height="200"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<dataSourceExpression>$P{DS}</dataSourceExpression>

<subreportExpression class="java.lang.String"><![CDATA["SubReport.jasper"]]></subreportExpression>

</subreport>

 

Is this the correct way? Because I keep getting this error:

[java] dori.jasper.engine.JRException: Error loading object from file : C:

jasperJasperReportsdemosamplestestMain.xml

 

 

 

 

By: Wesley Ng - abrabra

RE: Subreports

2003-03-19 02:36

In the program I do something like:

parameters.put("DS", new JRTableModelDataSource(new DS2()));

JasperFillManager.fillReportToFile(fileName1, parameters, new JRTableModelDataSource(new DS1()));

 

And in the Main.xml:

<parameter name="DS" isForPrompting="true" class="dori.jasper.engine.JRDataSource"/>

.

.

.

.

<subreport isUsingCache="true">

<reportElement

mode="Opaque"

x="10"

y="95"

width="516"

height="200"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<dataSourceExpression>$P{DS}</dataSourceExpression>

<subreportExpression class="java.lang.String"><![CDATA["SubReport.jasper"]]></subreportExpression>

</subreport>

 

Is this the correct way? Because I keep getting this error:

[java] dori.jasper.engine.JRException: Error loading object from file : C:

jasperJasperReportsdemosamplestestMain.xml

 

 

 

 

By: Teodor Danciu - teodord

RE: Subreports

2003-03-19 04:24

 

Hi,

 

Make sure you pass the Main.jasper file to the

fill method and not the Main.xml file.

 

I hope this helps.

Teodor

 

 

 

 

 

By: Wesley Ng - abrabra

RE: Subreports

2003-03-19 19:14

Hi, Teodor

 

Thanks for ur help! Able to generate the report already!

 

Regards

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...