Jump to content

How to hide table header for xlsx report?


NadeinNick
Go to solution Solved by lucianc,

Recommended Posts

Hello, I am using Jaspersoft Studio 6.20.5, and I am wondering it is possible to hide Table Header for xlsx files. I have created report, that is used for export to csv and xlsx files, but for xlsx file I don't need table header - first row,  and I am wondering it is possible to hide it? I tried following:
1) Pass  reportFormat variable through parameters, something like this:

private Resource createReport(List<Object> collection, String documentType) {
JRBeanCollectionDataSource dataSource = new JRBeanCollectionDataSource(collection);
Map<String, Object> parameters = new HashMap<>();
parameters.put("CollectionBeanParam", dataSource);
if (CSV.getValue().equalsIgnoreCase(documentType)) {
parameters.put(REPORT_FORMAT, CSV.getValue());
JasperPrint jasperPrint = JasperFillManager.fillReport(report, parameters, new JREmptyDataSource());
return writeCsvReport(jasperPrint);
} else {
parameters.put(REPORT_FORMAT, XLSX.getValue());
JasperPrint jasperPrint = JasperFillManager.fillReport(report, parameters, new JREmptyDataSource());
return writeXlsxReport(jasperPrint);
}

and the use it in report, by "Print when expression" on row :  $P{reportFormat}.equals("csv"), but it doesn't work and I got error when compile report in jasperReport studio:
Paramenter not foind: reportFormat --- net.sf.jasperreports.engine.design.JRDesignExpression@70015257
I think it's because tableHeader is rendering before getting reportFormat parameter.

2) Then I tried properties, something like this:

<property name="net.sf.jasperreports.export.xlsx.exclude.origin.band.1" value="pageHeader"/>
<property name="net.sf.jasperreports.export.xlsx.exclude.origin.band.2" value="tableHeader"/>
<property name="net.sf.jasperreports.export.xlsx.exclude.origin.band.3" value="pageFooter"/>
<property name="net.sf.jasperreports.export.xlsx.exclude.origin.band.4" value="lastPageFooter"/>

Properties for pageHeader and lastPageFooter works, but properties for tableHeader doesn't. I will appreciate any help.

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

  • Solution

Try something like this:

    <property name="net.sf.jasperreports.export.xlsx.exclude.origin.band.x" value="title"/>
    <property name="net.sf.jasperreports.export.xlsx.exclude.origin.report.x" value="*"/>

Regards,

Lucian

Link to comment
Share on other sites

  • 3 weeks later...

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