2005 IR Help Posted September 1, 2006 Share Posted September 1, 2006 By: rwdenney5 - rwdenney5 Export to csv 2005-02-02 15:41 Hi, I'm trying to use the same report for both pdf and csv exporting. The pdf output looks great, but I'm struggling with the csv. I have a few different questions so feel free to respond to any or all of them. 1. When I run the report as a csv type from my jsp page, a dialog box comes up asking whether I want to open the file or save it. The problem is that it's trying to save the report as an xls file rather than csv. How can I get it to save as a csv without manually changing the file extension each time? 2. I have the column headers set up in the column header band. Is there a way to get the column headers to print only once if the export type is csv? 3. Similar to the last question... I have the date and page number in the page footer band. How can I get these to not print when the export type is csv? 4. This is probably more a question I should ask in an excel forum, but I'll give it shot here... Obviously exporting to csv strips all the formatting. I'm trying to determine the best way to format the csv. If you have any suggestions, or resources you can turn me on to I'd really appreciate it. Thanks, Ryan Link to comment Share on other sites More sharing options...
shu.yi.eutech Posted November 12, 2012 Share Posted November 12, 2012 some answers:To export the file as a CSV that MS Excel can open, you need to set ';' as separator. You can do it by creating a JRCsvExporter object and call its method:setParameter(JRCsvExporterParameter.FIELD_DELIMITER, ";"); Then you can set manually the output file name and extension by the method;setParameter(JRExporterParameter.OUTPUT_FILE_NAME, "test.csv");To ignore header and footer, we are supposed to use attributes in the file jasperreports.properties, like these:net.sf.jasperreports.export.csv.exclude.origin.band.1=pageHeader net.sf.jasperreports.export.csv.exclude.origin.band.2=pageFooter There is a reference about them: http://jasperreports.sourceforge.net/config.reference.html#net.sf.jasperreports.csv.sourceI think in most cases we are supposed to use the same template for both PDF and CSV, for maintenance's sake.However I too am facing other problems with CSV. I integrated Jasper Reports version 4.7.0 into a J2EE 1.7 web application and I tried to generate pdf, csv files from a JSF page backed by jsf managed bean, and Glassfish server. So I developed utility classes for JasperReports.I also used my utility classes in a session EJB that create and send pdf, csv periodically. The periodicity is controlled by TimerService.When my CSV file exceeds two pages, the data lines on the second pages are repeated once, in both JSF page and Session EJB. In PDF I don't have such problem. (For example, the report has 30 lines in total and each page can contains 25 lines. in the CSV file we have the 25 lines on the first pages, and the remaining 5 lines appears twice on the second page. In pdf the last 5 lines appears only once, as expected.)I also wrote a standalone main class that generate PDF, CSV with the same template but it had no problem with CSV. 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