Zicks Posted May 14, 2008 Share Posted May 14, 2008 Hi, I'm currently using jasperreport in a java application that export .csv files into .pdf using .jasper files. I'm having a few issues with .csv file format.If you try to open a csv file with an editor like notepad++ you can see that "End of line" characters are different whether the file is windows (EoL is 'CRLF') or unix formatted (EoL is 'LF'). The wierd thing is : when I use jasperreports inside my java application, csv file (windows format) won't work and jasper says "Unknown column name X" (even though 'X' is the correct field).But unix format csv file works just fine. Even wierder, when I try with iReports, it works whether the csv file are windows or linux or whatever format. Is there a way to convert a file from windows to unix format with just java code, as I can't convert every csv file manually. Thanks in advance. Edit : sorry double post.Post edited by: Zicks, at: 2008/05/14 13:41 Link to comment Share on other sites More sharing options...
lucianc Posted May 14, 2008 Share Posted May 14, 2008 The JR CSV data source implementation has an attribute named recordDelimiter which it uses to split the CSV file into records. The delimiter is by default LF, and can be changed via setRecordDelimiter(). If you know in advance which files have CRLF end of lines, you could instruct the CSV data source instance to use CRLF as record delimiter. The reason CSV data sources work differently in iReport is that iReport uses its own CSV data source implementation - it.businesslogic.ireport.connection.JRCSVDataSource (which I think predated JR's CSV data source implementation). You could consider adopting this data source instead of the JR one if it works better for you. Regards,Lucian Link to comment Share on other sites More sharing options...
Zicks Posted May 15, 2008 Author Share Posted May 15, 2008 Thanks for your help. I'll have to try with setRecordDelimiter() the "old" JRCSVdatasource to decide what's better for me. At least now I have a lead ! :laugh: 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