Excel report with a sheet per group

Hi all:

I need to export a report into excel format generating a sheet per group, but I don't want to split the group in various sheets.

If I set IS_ONE_PAGE_PER_SHEET property to false, the exporter ignore "start on a new page" group property and generate the entire report in a unique sheet.

If I set IS_ONE_PAGE_PER_SHEET property to true, the group splitted in various sheets.

Any suggestions?

Thanks in advance.

Miguel

macivic's picture
90
Joined: Dec 14 2009 - 3:26am
Last seen: 8 years 2 months ago

19 Answers:

You can have explicit Excel sheet breaks by using the net.sf.jasperreports.export.xls.break.before.row and net.sf.jasperreports.export.xls.break.after.row properties on report elements.

HTH,

Lucian

lucianc's picture
72517
Joined: Jul 17 2006 - 1:10am
Last seen: 5 hours 50 min ago

Thank you Lucian,

Those properties works fine. The only restriction is they only can be use with JRPrintElement, and Group isn't an instance of this class.

I resolved it adding a line at group footer with line width 0 (invisible). I set the net.sf.jasperreports.export.xls.break.after.row property to true in the line and the report break in each group.

I don't know if it was the best solution or you have another suggestion.

Miguel

macivic's picture
90
Joined: Dec 14 2009 - 3:26am
Last seen: 8 years 2 months ago

I don't have any better suggestions, the properties can only be set for report elements.

Regards,

Lucian

lucianc's picture
72517
Joined: Jul 17 2006 - 1:10am
Last seen: 5 hours 50 min ago

Thank you for your post. I was able to generate a sheet per group using net.sf.jasperreports.export.xls.break.before.row.

However, I have another little issue : I don't know how to set the sheets' names.

I have 3 reports (3 jrxml) which generate an unique Excel file with 3 sheets. I tried setting the sheets' names with net.sf.jasperreports.export.xls.sheet.names.sheet1, net.sf.jasperreports.export.xls.sheet.names.sheet2 and net.sf.jasperreports.export.xls.sheet.names.sheet3 properties. The name of the first sheet is OK but the sheets 2 and 3 are named with the name of the first sheet following by 2 and 3.

For example, if the names are "toto", "titi" and "tutu", the sheets' names will be "toto", "toto 2" and "toto 3".

 

Are you able to define the sheets' names correctly ?

toomtooms's picture
261
Joined: Jan 4 2010 - 2:17am
Last seen: 13 years 2 months ago

Hi,

 

How did you export the 3 reports to the same XLS file? Using batch export (JASPER_PRINT_LIST export parameter)?

What exporter class did you use? The JRXlsExporter or the JExcelApiExporter?

Where did you set the 3 sheet name config properties? In a jasperreports.properties file or in the first report template?

 

Thank you,
Teodor

 

teodord's picture
44871
Joined: Jun 30 2006 - 9:00am
Last seen: 1 week 2 days ago

How did you export the 3 reports to the same XLS file? Using batch export (JASPER_PRINT_LIST export parameter)?

I use Java API :

        JasperPrint jasperPrintFeuilleTexte = JasperFillManager.fillReport(DirectoryLocator.getIntradocDir() + "custom/CustomizedContribution/resources/reports/stats-texte.jasper", paramsTexte, new JREmptyDataSource());
        JasperPrint jasperPrintFeuilleStatsPDV = JasperFillManager.fillReport(DirectoryLocator.getIntradocDir() + "custom/CustomizedContribution/resources/reports/stats-pdv.jasper", new HashMap(), statsPdvDataSource);
        JasperPrint jasperPrintFeuilleStatsCentrale = JasperFillManager.fillReport(DirectoryLocator.getIntradocDir() + "custom/CustomizedContribution/resources/reports/stats-centrale.jasper", new HashMap(), statsCentraleDataSource);
        List pagesStatsPDV = new ArrayList(jasperPrintFeuilleStatsPDV.getPages());
        for(int count = 0; count < pagesStatsPDV.size(); count++)
        {
            jasperPrintFeuilleTexte.addPage((JRPrintPage) pagesStatsPDV.get(count));
        }
        List pagesStatsCentrale = new ArrayList(jasperPrintFeuilleStatsCentrale.getPages());
        for(int count = 0; count < pagesStatsCentrale.size(); count++)
        {
            jasperPrintFeuilleTexte.addPage((JRPrintPage)pagesStatsCentrale.get(count));
        }
 

What exporter class did you use? The JRXlsExporter or the JExcelApiExporter?

JRXlsExporter

Where did you set the 3 sheet name config properties? In a jasperreports.properties file or in the first report template?

I tried in different locations :

- in the first report template

- in each report template

- in the JRXlsExporter parameters : exporterXLS.setParameter(JRXlsExporterParameter.SHEET_NAMES, new String[]{"toto", "titi", "tutu"});

I have the same results with all these locations.

Thank you

Thomas

toomtooms's picture
261
Joined: Jan 4 2010 - 2:17am
Last seen: 13 years 2 months ago

Hi,

 

What version of JasperReports are you using when trying to set the sheet names.

 

Thanks,

Teodor

 

teodord's picture
44871
Joined: Jun 30 2006 - 9:00am
Last seen: 1 week 2 days ago

I am using JasperReports 3.6.1.

 

Thomas

toomtooms's picture
261
Joined: Jan 4 2010 - 2:17am
Last seen: 13 years 2 months ago

Hi,

 

I was not able to reproduce this problem.

Download the JR 3.6.1 project distribution from Sourceforge.net and copy the attached file in the /demo/samples/batchexport sample.

Then run it with ant like this:

>ant clean javac compile fill xls

 

You'll notice the first three sheet names coming nicely. They are set using the SHEET_NAMES exporter parameter. But setting them with custom properties in the first of the reports (the other two do not matter anyway), works as well, provided that you no longer set the SHEET_NAMES, which would take precendence.

 

I hope this helps.

Teodor

 



Post Edited by teodord at 01/21/2010 11:13
teodord's picture
44871
Joined: Jun 30 2006 - 9:00am
Last seen: 1 week 2 days ago

lucianc
Wrote:

You can have explicit Excel sheet breaks by using the net.sf.jasperreports.export.xls.break.before.row and net.sf.jasperreports.export.xls.break.after.row properties on report elements.

HTH,

Lucian

 

 

Hi.

could anybody paste the code to use this properties. I don't know how i should use them.

Thank's a lot

stopbugginme's picture
Joined: Apr 28 2009 - 6:19am
Last seen: 9 years 3 months ago

stopbugginme
Wrote:

lucianc
Wrote:

You can have explicit Excel sheet breaks by using the net.sf.jasperreports.export.xls.break.before.row and net.sf.jasperreports.export.xls.break.after.row properties on report elements.

HTH,

Lucian

 

 

Hi.

could anybody paste the code to use this properties. I don't know how i should use them.

Thank's a lot

Hi everyone,

I tried to enable these two properties, doing this but it does not work:

               

Can someone help me please, i need it urgently.

thanks a lot.

Julien.

Code:
JRXlsExporter exporterXLS = new JRXlsExporter();                 exporterXLS.setParameter(JRXlsExporterParameter.is_break_before_row, Boolean.TRUE);         
exporterXLS.exportReport();</td></tr></tbody></table>
zados's picture
189
Joined: Jul 23 2010 - 8:28pm
Last seen: 12 years 8 months ago

I am still wondering if there is someone who can help me find the answer to my questions.

Great thanks...

 

zados's picture
189
Joined: Jul 23 2010 - 8:28pm
Last seen: 12 years 8 months ago

is this forum still working /:

zados's picture
189
Joined: Jul 23 2010 - 8:28pm
Last seen: 12 years 8 months ago

The forum is working, but not necessarily in an "urgent" mode.

The properties I mentioned need to be set at element level, as documented.  So you'd have something like below in your report.

Regards,

Lucian

Code:
<textField>
	<reportElement x="0" y="0" ...>
		<property name="net.sf.jasperreports.export.xls.break.before.row" value="true"/>
	</reportElement>
</td></tr></tbody></table>
lucianc's picture
72517
Joined: Jul 17 2006 - 1:10am
Last seen: 5 hours 50 min ago

I tried a lot of ways. I checked "ignore pagination", then set "break.after.row" to true to some element.

 

It worked in ireport. But when i open the report in jasperserver, only one sheet is generated.

 

Could you please tell me why? I am using Jasperserver 3.7.1, ireport 4.0.0.

 

Do I have to upgrade jasperserver to 4.0?

 

Thanks

taiko's picture
151
Joined: Mar 15 2011 - 3:53pm
Last seen: 12 years 1 week ago

 Export time settings on iReport are not magically set in JasperServer - you'll have to find /WEB-INF/classes/jasperreports.properties and set them there.

ernestoo's picture
18058
Joined: Nov 29 2010 - 11:59am
Last seen: 5 years 5 months ago

thanks

cjasper - 10 years 3 months ago

It works!! I just add

net.sf.jasperreports.export.xls.break.after.row=true

in jasperreports.properties

 

Thanks a lot !

taiko's picture
151
Joined: Mar 15 2011 - 3:53pm
Last seen: 12 years 1 week ago
  1. Add this net.sf.jasperreports.export.xls.one.page.per.sheet and its value:true to the report's properties.

  2. Add Group Band and give Group Expression in Group Header or in Group Footer.

  3. Add a Page Brake in Page footer or Group footer or after the crosstab data or data.

  4. Check on ignore pagination.

Result: You will find the Excel report with a sheet per group.

 

ansulgupta's picture
Joined: Aug 17 2012 - 2:50am
Last seen: 10 years 7 months ago

I have done everything mentioned within this thread and still have not been able to produce the desired results. Using Ireport 5.0

wolverto - 9 years 11 months ago

Did you have any luck in this,I am using 6.2.0 and have the same issue.

manogna - 7 years 2 weeks ago

I checked “Start New Page” for my group header (and group footer). Therefore I got rid of the the page break.
I UNchecked the “Ignore Pagination” for the report. But mind, that the page height must be tall enough to hold the content for every sheet or you get “funny” sheets in between.

johannes.held - 6 years 7 months ago
show 1 more...

We need to below property to the line which we added in the table footer
net.sf.jasperreports.export.xls.sheet.name -- Use an expression to select the field name to you want to keep

prasannaj_1 - 4 years 6 months ago

After adding line in the footer section, go to the line advanced properties and add 


net.sf.jasperreports.export.xls.sheet.name - Use an expression 


 

 

prasannaj_1's picture
Joined: May 14 2018 - 11:14pm
Last seen: 4 years 6 months ago
Feedback