goompas Posted April 1, 2009 Share Posted April 1, 2009 HelloI have in DB colors of textfields from my reports. How can i set colors text of textfields(type Double) using colors from DB ?I know that i can use styled text but then i must have textfield type String, but i need textfield type Double to export report to xls and then using it.Can i edit report after filling to jasperPrint but before generate xls? If yes, then i can check field color and set color of textfield.There is dynamic numbers of rows and not all haved that same color.I have field that stored color.Row 1-20 redRow 21-23 - oragneetcColors are defined by user and stored in DB.I see AlterDesign sample, but it show how edit report structure from jrxml and then i have one color for all rows.Post Edited by goompas . at 04/01/09 11:01 Link to comment Share on other sites More sharing options...
dnvsrikanth Posted April 1, 2009 Share Posted April 1, 2009 Hi, Retrieve the colors from report query and apply the corresponding color to the text field by using styles..... If am not wrong we cant edit the report after filling the report, before generating the report in xls format as the same JasperPrint object is used to export the report. DNV Srikanth.Post Edited by Srikanth DNV at 04/01/09 11:41 Link to comment Share on other sites More sharing options...
goompas Posted April 1, 2009 Author Share Posted April 1, 2009 Thx for answer I cant apply field/parameter/variable to color in style, its must be StringFor second answer, how to get these elements from jasperPrint? Link to comment Share on other sites More sharing options...
dnvsrikanth Posted April 1, 2009 Share Posted April 1, 2009 hi, can u elaborate your report requirements, because we are retriving the colors from database and applying those colors to the text field using styles in our reports. DNV Srikanth. Link to comment Share on other sites More sharing options...
goompas Posted April 1, 2009 Author Share Posted April 1, 2009 Can you show in jrxml how you dit it? Link to comment Share on other sites More sharing options...
dnvsrikanth Posted April 2, 2009 Share Posted April 2, 2009 Hi, It cant be possible to show the jrxml as it needs to be kept confidential. So Its better you tell me about the requirement of the report so that I can help you out to resolve the problem. DNV Srikanth. Link to comment Share on other sites More sharing options...
goompas Posted April 2, 2009 Author Share Posted April 2, 2009 Primary:I need change dynamic color of textfiled that type is java.lang.Double(BigDecimal, only number not String). These color i get from datasorce as field.Raport structure is like this:A B C D E F G ...1 1 1 1 1 1 1 1 ...2 2 2 2 2 2 2 2 ...3 3 3 3 3 3 3 3 .....Every point can have different color, that is stored in object from field.I cant i conditional style setting forecolor use this formula$F{value}[0].getColor()It can be only like this: #33FF33Im only need set dynamicly forecolor or backcolor in conditional style and this color cant be static because i get it together with field. I try too this: List jpages = jasperPrint.getPages(); System.out.println("pages size " + jpages.size()); for (int i = 0; i < jpages.size(); i++) { JRPrintPage page = (JRPrintPage) jpages.get(i); List elementy = page.getElements(); System.out.println("lista elementow strona " + i + " elementow " + elementy.size()); for (int j = 0; j < elementy.size(); j++) { // JRPrintElement element = (JRPrintElement) elementy.get(j); System.out.println("page " + i + " element " + j); JRTemplatePrintText text = (JRTemplatePrintText) elementy.get(j); System.out.println("get forecolor " + text.getForecolor()); System.out.println("text backcolor"+text.getBackcolor()); Color color=new Color(255,0,255); text.setMode(JRElement.MODE_OPAQUE); System.out.println("color "+color); text.setForecolor(color); text.setBackcolor(color); System.out.println("po zmianie forecolor "+text.getForecolor()); System.out.println("po zmianie backcolor "+text.getBackcolor()); } } but this text.setForecolor(color); text.setBackcolor(color);dont work for me, its dont change color.And here is another question: can i from jasperPrint get elements of report rom by key? Like getElementByKey() ?sorry for my english but i think you understand :)Post Edited by goompas . at 04/02/09 08:55 Link to comment Share on other sites More sharing options...
dnvsrikanth Posted April 2, 2009 Share Posted April 2, 2009 Hi, U can convert those integers into strings using toString() function and retrieve the colors from report query and apply styles accordigly. DNV Srikanth.Post Edited by Srikanth DNV at 04/02/09 12:49 Link to comment Share on other sites More sharing options...
goompas Posted April 3, 2009 Author Share Posted April 3, 2009 Thx for answerYes i know that and try that, but i dont wanna have numbers as Strings and styled text dont work in excel. I need have it as Double, Integer, Bigdecimal(numbers) because later i export raport to xls and need that excel see it as numbers, not strings.Post Edited by goompas . at 04/03/09 06:32 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