roarf Posted January 17, 2013 Share Posted January 17, 2013 Hi,I have a report that may look like this simplified:String, String, Integer, Integer, StringOr sometimes, i could change dynamicaly and look like this:String, String, String, Integer, IntegerOr any other combination.Is there any way i can get Excel reports to format numbers as numbers and strings as strings?I can't set the correct datatypes of my textfields in templates, because it is determined on runtime. The only way I see i using the API to replace textfields with designTextfields, which can have their class type set.Am I missing something, or is this the only way? Any help is very appreciated:) Link to comment Share on other sites More sharing options...
sanbez Posted January 17, 2013 Share Posted January 17, 2013 Are you use java for export or only iReport? The ways is different... Link to comment Share on other sites More sharing options...
sanbez Posted January 17, 2013 Share Posted January 17, 2013 Additional question. Which version of JR (iReport) ? Link to comment Share on other sites More sharing options...
kcollins Posted January 17, 2013 Share Posted January 17, 2013 You probably need to set the property net.sf.jasperreports.export.xls.detect.cell.type to true on your report. See here:http://jasperreports.sourceforge.net/config.reference.html#net.sf.jasperreports.export.xls.detect.cell.type-Kris Link to comment Share on other sites More sharing options...
kcollins Posted January 17, 2013 Share Posted January 17, 2013 Actually.. If you don't know what datatype the fields will be, how do you have them set in the report? I'm pretty sure it just going to determine the cell type based on the datatype of the field, which will remain static after the report is created. How are you dynamically changing the datatypes of the fields in the report? Link to comment Share on other sites More sharing options...
roarf Posted January 18, 2013 Author Share Posted January 18, 2013 That is excatly what I'm wondering how to do. I think "detect cell types" only will read the type of the textfield in the report template, and convert the value to it. What I need is the other way: to read the type of the value, and convert the textfield to it.. Link to comment Share on other sites More sharing options...
roarf Posted January 18, 2013 Author Share Posted January 18, 2013 I design i ireport, but do the export in Java. I use JR 4.0.1, but are willing to upgrade if nescessary. Link to comment Share on other sites More sharing options...
sanbez Posted January 18, 2013 Share Posted January 18, 2013 It seems to me this is incorrect attempt to solve the problem of bad data (error in design DB?). Each attribute should be have exact type. Link to comment Share on other sites More sharing options...
roarf Posted January 18, 2013 Author Share Posted January 18, 2013 No, the problem is that the number and order of columns in the report should change dynamically, based on what choices the user makes before generation. Link to comment Share on other sites More sharing options...
sanbez Posted January 18, 2013 Share Posted January 18, 2013 I do not see any solutions. Just rewrite (extend? class) the report generator to specify the exact type of the fields. And after that set "auto detect cell type" (Kris answer). Link to comment Share on other sites More sharing options...
shertage Posted January 29, 2013 Share Posted January 29, 2013 Hi, Maybe this one would work: try to use 2 separate textfields with valid printWhenExpressions, sharing the same position in the report. Use one of them to render String values only, and the other one for numeric values. 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