Jump to content
Changes to the Jaspersoft community edition download ×

Crosstab with a custom data source?


2004 IR Help

Recommended Posts

By: Szia - sziab

Crosstab with a custom data source?

2005-11-30 12:31

Hi,

 

Can I use a crosstab with a custom data source?

If so, is there an example or more info on how to this?

 

Thx,

Sinziana

 

 

 

 

By: Szia - sziab

RE: Crosstab with a custom data source?

2005-12-01 12:47

Hi,

 

I'm trying to replace the jdbc data source in the

ShipmentsReport crosstab example with a custom data source like:

private Object[][] data = {

{"USA", "AK", "A", "1997", "Jan", new Float(1.1) },

{"USA", "AK", "A", "1997", "Feb", new Float(2.2)},

};

 

With only 1 row of data my report fills & displays OK, but adding the 2nd row will throw a JRException: Crosstab data has already been processed. (stacktace below)

 

So my question again is how can I use a custom data source in a crosstab?

 

Thx,

S.

 

 

fill:

[java] net.sf.jasperreports.engine.JRException: Crosstab data has already been processed.

[java] at net.sf.jasperreports.crosstabs.fill.calculation.BucketingService.addData(BucketingService.java:210)

[java] at net.sf.jasperreports.engine.fill.JRFillCrosstab$JRFillCrosstabDataset.customIncrement(JRFillCrosstab.

java:1092)

[java] at net.sf.jasperreports.engine.fill.JRFillElementDataset.increment(JRFillElementDataset.java:132)

[java] at net.sf.jasperreports.engine.fill.JRCalculator.calculateVariables(JRCalculator.java:154)

[java] at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:579)

[java] at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportContent(JRVerticalFiller.java:249)

[java] at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:131)

[java] at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:834)

[java] at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:89)

[java] at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:428)

[java] at net.sf.jasperreports.engine.JasperFillManager.fillReportToFile(JasperFillManager.java:319)

[java] at net.sf.jasperreports.engine.JasperFillManager.fillReportToFile(JasperFillManager.java:275)

[java] at AsResultTableApp.main(AsResultTableApp.java:83)

 

 

 

 

 

 

By: Lucian Chirita - lucianc

RE: Crosstab with a custom data source?

2005-12-01 23:41

Hi

 

I see that your crosstab is placed on the report's detail band. This would render a crosstab for each row in the data source. Is this what you want?

 

Regards,

Lucian

 

 

 

 

By: Szia - sziab

RE: Crosstab with a custom data source?

2005-12-02 18:57

That was certainly not what I wanted, I've moved my crosstab in the summary band and everyhting's fine now!

 

Thanks much!

Sinziana

 

 

 

 

By: Lalith - weeralalith

RE: Crosstab with a custom data source?

2006-03-23 20:55

Hi Lucian,

 

I have put my crosstab in my sub report's detail band (this sub report contain only this particular crosstab and is called inside a header band in the master report). That render the crosstab for each raw in the data source. So then I tried keeping the crosstab in the summary band, then it worked. But may i know the best way to resolve this problem rather than keeping it in the summary band? Please response to this ASAP. This is very ergent.

 

 

 

 

By: Lalith - weeralalith

RE: Crosstab with a custom data source?

2006-03-23 20:56

Hi Lucian,

 

I have put my crosstab in my sub report's detail band (this sub report contain only this particular crosstab and is called inside a header band in the master report). That render the crosstab for each raw in the data source. So then I tried keeping the crosstab in the summary band, then it worked. But may i know the best way to resolve this problem rather than keeping it in the summary band? Please response to this ASAP. This is very ergent.

 

Thanks,

Lalith

 

 

 

 

By: Lucian Chirita - lucianc

RE: Crosstab with a custom data source?

2006-03-24 06:17

Hi

 

I don't really understand your question. What's wrong with the crosstab being on the summary band? Also, if you put an element on the detail band, it will obviously get rendered for each row in the data source.

 

A crosstab should be placed on a band that gets rendered after all the data required by the crosstab is available. Another option is to use a sub dataset for the crosstab, in which case you can place the crosstab anywhere.

 

HTH,

Lucian

 

 

 

 

By: Lalith - weeralalith

RE: Crosstab with a custom data source?

2006-03-27 23:12

Hi Lucian,

 

I'm sending a JRDataSource to the main report. In this datasource i have 6 data columns. (col A,B,C,D,E,F in the actual table).

 

Now i'm grouping the data as

Group 1 : A

Group 1 : B

Group 1 : C

And inside this group C Band i need to put a crosstab and display only the data related to group C in the crosstab.

 

So my approach was like this.

 

1. Add an subreport in Group C

2. Use $P{REPORT_DATA_SOURCE} in the subreport property tab as DataSource Expression

3. In my subreprot i have only one crosstab (nothing else, no any other elements in that report). And i've kept it in summary band of subreport.

 

So When i run the report with one (1) group C dataset ( menaing only one data element, say "gC_data_1", for group C) then the crosstab display the data correctly.

 

But when Group C have distinct data more than one there we can see the "net.sf.jasperreports.engine.JRException: Crosstab data has already been processed" exception.

 

To get rid of this I want to create a subdataset out of my main dataset and send it to the subreport so that the crosstab directly use that and disply data only related to the current group C.

 

Can you please give me some guidlines how to create this dynamic subdataset out of the main report's JRDataSource ?

 

Thanks,

Lalith

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...