andre.erasmus Posted July 2, 2013 Share Posted July 2, 2013 I want to export to CSV with the Header and Footer only showing onceThe current output:Name Address HobbyAAA US XXXXXBBB UK XXXXX(Footer)Name Address HobbyCCC ID XXXXXDDD CC XXXXX(Footer)Name Address HobbyEEE SA XXXXXFFF ZM XXXXX(Footer) The desired output:Name Address HobbyAAA US XXXXXBBB UK XXXXXCCC ID XXXXXDDD CC XXXXXEEE SA XXXXXFFF ZM XXXXX(Footer) So how do I get the Header and footer to only show once ? Link to comment Share on other sites More sharing options...
Ankur Gupta Posted July 3, 2013 Share Posted July 3, 2013 Hi,This could be done by using the print when expression for tghe page header band as $V{PAGE_NUMBER} == 1This will solve the purpose for the page header For the page footer for the last page you can simply use the band name LAST PAGE FOOTER Hope that this helps Thanks,Ankur Gupta Link to comment Share on other sites More sharing options...
andre.erasmus Posted July 3, 2013 Author Share Posted July 3, 2013 When I export to xls, it works, but not to CSV I still want the headers there when viewed as PDF, so they should just be hidden when exporting to CSV (I know this has to be possible because it works like this for my "export to xls") Link to comment Share on other sites More sharing options...
Ankur Gupta Posted July 4, 2013 Share Posted July 4, 2013 Hi,If you are following the way I described it will work fine for csv .Now if you want to vary the layout of header and footers then you could simply add a parameter suppose $P{OUTPUT_FORMAT} which takes user input to decide the layout the choices which user could enter would be "CSV","PDF","XLS" .. etc. according to you needs. Suppose you have that parameter $P{OUTPUT_FORMAT} -I am here explaning in "CSV" and "PDF"CASE 1:When user enters CSVThe print when expression for report header would be $P{OUTPUT_FORMAT} == "CSV" && $V{PAGE_NUMBER}==1Now this will give you the header for the report only on the first page in the case of CSV Format CASE 2:When user enters PDFThe print when expression for report header would e $P{OUTPUT_FORMAT} == "PDF" Now to provide dynamism you can combine the PrintWhenExpressions like $P{OUTPUT_FORMAT} == "PDF" || ($P{OUTPUT_FORMAT} == "CSV" && $V{PAGE_NUMBER}==1) Now here I have combined for PDF and CSV but you can do this in any other format I have depicted the same in a sample JRXML it uses the sample database.And also attaching the CSV and PDF Exports. Hope that it helps. Thanks,Ankur Gupta Link to comment Share on other sites More sharing options...
andre.erasmus Posted July 4, 2013 Author Share Posted July 4, 2013 Thx man, This will definitely work, was just looking for a way to do this in the jasper code, as there is about 400 reports this will have to be added to Link to comment Share on other sites More sharing options...
Ankur Gupta Posted July 4, 2013 Share Posted July 4, 2013 You are welcome Cheers!! Link to comment Share on other sites More sharing options...
jay_2 Posted March 6, 2015 Share Posted March 6, 2015 Brilliant solution, Ankur. Thank you. Too bad it's so difficult to implement such an obvious thing. Jay Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now