Jump to content
We've recently updated our Privacy Statement, available here ×

p_a

Members
  • Posts

    59
  • Joined

  • Last visited

p_a's Achievements

Enthusiast

Enthusiast (6/14)

  • Week One Done
  • One Month Later
  • One Year In
  • First Post Rare
  • Collaborator Rare

Recent Badges

0

Reputation

  1. Hi, I got the solution.Here is the code for the ones who have the same problem. new Double($F{id}.longValue()==1 ? ($F{b}.doubleValue()!=0? (($F{a}.doubleValue())*100)/($F{b}.doubleValue()): 0): (($F{b}.doubleValue()!=0? (($F{c}.doubleValue())*100)/($F{b}.doubleValue()): 0) ) ) Thank you, Pegah
  2. Hi, I have a condition statement as showed below: if(id==1){ a*100/b } else{ c*100/b } iReport Format : new Double($F{id}.longValue()==1? (($F{a}.doubleValue())*100)/($F{b}.doubleValue()): (($F{c}.doubleValue())*100)/($F{b}.doubleValue())) Now I wanna do another check for denominator, b, if(id==1){ if(b!=null){a*100/b} else{doOther thing} } else{ if(b!=null){c*100/b} else{doOther thing} } I don't know how could I write the new condition in ireport format. Looking forward any tip. Thank you, Pegah
  3. Hi lshannon, Thanks for your reply.I'll use your tip and will see if it works in my report as well. Thank you, Pegah
  4. Hi, I solved my problem with putting my textFields in Frame.This may not be a good solution but I could not find any:( Another case I faced with my reports is, when I change my report several times sometimes the changes did not work well and make my report unusual!!! I still am looking forward the better solution and appreciate any help and suggestion. Thank you, Pegah
  5. Hi, I have a report with 2 sub reports in it.when I generate the html report the textField width size changes according to its content. I set the textField property stretch type:No stretch and I use the following code in my servlet to generate html report: Code: JRHtmlExporter exporterHTML = new JRHtmlExporter(); ByteArrayOutputStream htmlReport = new ByteArrayOutputStream(); request.getSession().setAttribute(ImageServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE, jasperPrint); exporterHTML.setParameter(JRHtmlExporterParameter.IMAGES_URI,"image?image="«»); exporterHTML.setParameter(JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN,Boolean.FALSE); exporterHTML.setParameter(JRHtmlExporterParameter.JASPER_PRINT, jasperPrint); exporterHTML.setParameter(JRHtmlExporterParameter.OUTPUT_STREAM, htmlReport); exporterHTML.setParameter(JRHtmlExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS,Boolean.TRUE); exporterHTML.setParameter(JRHtmlExporterParameter.IS_WRAP_BREAK_WORD,Boolean.TRUE); exporterHTML.setParameter(JRHtmlExporterParameter.BETWEEN_PAGES_HTML,"<div style='page-break-after:always'></div>" ); exporterHTML.setParameter(JRHtmlExporterParameter.FRAMES_AS_NESTED_TABLES,false); But as you see in the image I took from my report the width of my html report changes,it is just happened in html not in pdf. I searched a lot and tried all solutions I found but still the problem exist! Hope some one could give me a clue. Thank you, Pegah Post edited by: p_a, at: 2008/04/27 09:38 Post edited by: p_a, at: 2008/04/27 09:55 Post edited by: p_a, at: 2008/04/27 10:06
  6. Hi, I solved my problem.Just need to change some lines of code in this way: JRDesignField fieldVal = (JRDesignField) fieldList.get(i); String strField = fieldVal.getName(); expression.setText("$F{" + strField + "}"); Hope it also helped others who wanted to make dynamic reports. Thank you, Pegah
  7. Hi, I find the problem in my program.I have to new textField in each textField I want to have in detail band. textField = new JRDesignTextField(); And now I got another problem.As I said in previous post I want my column to be dynamic so I used this code for that : Code: int x = 0; List fieldList = jd.getFieldsList(); for(int i = 0;i<fieldList.size(); i++){ textField.setBlankWhenNull(true); textField.setWidth(107); textField.setHeight(55); textField.setX(x); textField.setY(0); textField.setRemoveLineWhenBlank(true); textField.setHorizontalAlignment(JRAlignment.HORIZONTAL_ALIGN_CENTER); textField.setVerticalAlignment(JRAlignment.VERTICAL_ALIGN_MIDDLE); textField.setStyle(normalStyle); textField.setBold(true); expression = new JRDesignExpression(); expression.setValueClass(java.lang.Integer.class); String fieldVal = fieldList.get(i).toString(); expression.setText(new String("$F{fieldVal}"«»)); expression.getText(); textField.setExpression(expression); band.addElement(textField); x = x + 107; } But the problem is when I want to setText in expression it gives me an error.It could not load the name of the field!!!! I would appreciate anyone who read this post and find a solution for it. Thank you, Pegah
  8. Hi again, Teodor thanks for concerning my previous post about /demo/samples/noxmldesign and your answer. It was helpful and now I pretty well understand the code. Now I faced a problem loading my fields value into Detail band. All parts of my report works well except detail band:S Here is my code: Code: public class JasperDesignMaker {//This is the inner class I used in my project JasperDesign jd; JRDesignStyle normalStyle; JRDesignStyle boldStyle; JRDesignParameter parameter; JRDesignQuery query; JRDesignField field; JRDesignBand band; JRDesignLine line; JRDesignStaticText staticText; JRDesignTextField textField; JRDesignExpression expression; public JasperDesignMaker(){ } public JasperDesign JasperMaker() throws JRException{ try{ jd = new JasperDesign(); //Page Properties jd.setPageWidth(595); jd.setPageHeight(842); jd.setColumnWidth(535); jd.setColumnCount(1); jd.setColumnSpacing(0); jd.setLeftMargin(30); jd.setRightMargin(30); jd.setTopMargin(20); jd.setBottomMargin(20); jd.setPrintOrder(jd.PRINT_ORDER_VERTICAL); jd.setWhenNoDataType(jd.WHEN_NO_DATA_TYPE_ALL_SECTIONS_NO_DETAIL); jd.setName("Template Report"«»); jd.setOrientation(jd.ORIENTATION_PORTRAIT); //Font Properties //Normal Font normalStyle = new JRDesignStyle(); normalStyle.setName("Sans_Serif"«»); normalStyle.setFontName("SansSerif"«»); normalStyle.setDefault(true); normalStyle.setFontSize(12); normalStyle.setPdfFontName("Helvetica"«»); normalStyle.setPdfEncoding("Cp1252"«»); normalStyle.setPdfEmbedded(true); jd.addStyle(normalStyle); //Bold Font boldStyle = new JRDesignStyle(); boldStyle.setName("Sans_Serif_Bold"«»); boldStyle.setFontName("SansSerif"«»); boldStyle.setFontSize(12); boldStyle.setBold(true); boldStyle.setPdfFontName("Helvetica-Bold"«»); boldStyle.setPdfEncoding("Cp1252"«»); boldStyle.setPdfEmbedded(true); jd.addStyle(boldStyle); //Parameters parameter = new JRDesignParameter(); parameter.setName("param0"«»); parameter.setValueClass(java.lang.String.class); jd.addParameter(parameter); parameter = new JRDesignParameter(); parameter.setName("param1"«»); parameter.setValueClass(java.lang.String.class); jd.addParameter(parameter); parameter = new JRDesignParameter(); parameter.setName("param2"«»); parameter.setValueClass(java.lang.String.class); jd.addParameter(parameter); parameter = new JRDesignParameter(); parameter.setName("param3"«»); parameter.setValueClass(java.lang.String.class); jd.addParameter(parameter); parameter = new JRDesignParameter(); parameter.setName("param4"«»); parameter.setValueClass(java.lang.String.class); jd.addParameter(parameter); parameter = new JRDesignParameter(); parameter.setName("dbQuery"«»); parameter.setValueClass(java.lang.String.class); jd.addParameter(parameter); //Query query = new JRDesignQuery(); query.setText("select * from test"«»); jd.setQuery(query); //Fields field = new JRDesignField(); if(param0!=null){ field.setName(param0.toSting()); field.setValueClass(java.lang.Integer.class); jd.addField(field); } if(param1!=null){ field.setName(param1.toString()); field.setValueClass(java.lang.Integer.class); jd.addField(field); } if(param2!=null){ field.setName(param2.toString()); field.setValueClass(java.lang.Integer.class); jd.addField(field); } if(param3!=null){ field.setName(param3.toString()); field.setValueClass(java.lang.Integer.class); jd.addField(field); } if(param4!=null){ field.setName(param4.toString()); field.setValueClass(java.lang.Integer.class); jd.addField(field); } //Report Bands //Title band = new JRDesignBand(); band.setHeight(50); line = new JRDesignLine(); line.setX(0); line.setY(0); line.setWidth(535); line.setHeight(0); band.addElement(line); staticText = new JRDesignStaticText(); staticText.setText("Report Template Test"«»); staticText.setHeight(50); staticText.setWidth(535); staticText.setTopPadding(0); staticText.setLeftPadding(0); staticText.setStyle(boldStyle); staticText.setFontSize(22); staticText.setPositionType(JRElement.POSITION_TYPE_FIX_RELATIVE_TO_TOP); staticText.setStretchType(JRElement.STRETCH_TYPE_NO_STRETCH); staticText.setMode(JRElement.MODE_TRANSPARENT); staticText.setHorizontalAlignment(JRAlignment.HORIZONTAL_ALIGN_CENTER); staticText.setVerticalAlignment(JRAlignment.VERTICAL_ALIGN_MIDDLE); staticText.setLineSpacing(JRTextElement.LINE_SPACING_SINGLE); staticText.setBold(true); staticText.setPadding(0); band.addElement(staticText); jd.setTitle(band); //PageHeader band = new JRDesignBand(); band.setHeight(0); jd.setPageHeader(band); band = new JRDesignBand(); band.setHeight(0); jd.setDetail(band); band = new JRDesignBand(); band.setHeight(0); jd.setPageFooter(band); band = new JRDesignBand(); band.setHeight(0); jd.setSummary(band); //Column header band = new JRDesignBand(); band.setHeight(55); textField = new JRDesignTextField(); textField.setBlankWhenNull(true); textField.setWidth(107); textField.setHeight(55); textField.setLeftPadding(0); textField.setTopPadding(0); textField.setRemoveLineWhenBlank(true); textField.setHorizontalAlignment(JRAlignment.HORIZONTAL_ALIGN_CENTER); textField.setVerticalAlignment(JRAlignment.VERTICAL_ALIGN_MIDDLE); textField.setStyle(boldStyle); textField.setBold(true); expression = new JRDesignExpression(); expression.setValueClass(java.lang.String.class); expression.setText("$P{param0}"«»); textField.setExpression(expression); band.addElement(textField); textField = new JRDesignTextField(); textField.setBlankWhenNull(true); textField.setWidth(107); textField.setHeight(55); textField.setX(107); textField.setY(0); textField.setRemoveLineWhenBlank(true); textField.setHorizontalAlignment(JRAlignment.HORIZONTAL_ALIGN_CENTER); textField.setVerticalAlignment(JRAlignment.VERTICAL_ALIGN_MIDDLE); textField.setStyle(boldStyle); textField.setBold(true); expression = new JRDesignExpression(); expression.setValueClass(java.lang.String.class); expression.setText("$P{param1}"«»); textField.setExpression(expression); band.addElement(textField); textField = new JRDesignTextField(); textField.setBlankWhenNull(true); textField.setWidth(107); textField.setHeight(55); textField.setX(214); textField.setY(0); textField.setRemoveLineWhenBlank(true); textField.setHorizontalAlignment(JRAlignment.HORIZONTAL_ALIGN_CENTER); textField.setVerticalAlignment(JRAlignment.VERTICAL_ALIGN_MIDDLE); textField.setStyle(boldStyle); textField.setBold(true); expression = new JRDesignExpression(); expression.setValueClass(java.lang.String.class); expression.setText("$P{param2}"«»); textField.setExpression(expression); band.addElement(textField); textField = new JRDesignTextField(); textField.setBlankWhenNull(true); textField.setWidth(107); textField.setHeight(55); textField.setX(321); textField.setY(0); textField.setRemoveLineWhenBlank(true); textField.setHorizontalAlignment(JRAlignment.HORIZONTAL_ALIGN_CENTER); textField.setVerticalAlignment(JRAlignment.VERTICAL_ALIGN_MIDDLE); textField.setStyle(boldStyle); textField.setBold(true); expression = new JRDesignExpression(); expression.setValueClass(java.lang.String.class); expression.setText("$P{param3}"«»); textField.setExpression(expression); band.addElement(textField); textField = new JRDesignTextField(); textField.setBlankWhenNull(true); textField.setWidth(107); textField.setHeight(55); textField.setX(428); textField.setY(0); textField.setRemoveLineWhenBlank(true); textField.setHorizontalAlignment(JRAlignment.HORIZONTAL_ALIGN_CENTER); textField.setVerticalAlignment(JRAlignment.VERTICAL_ALIGN_MIDDLE); textField.setStyle(boldStyle); textField.setBold(true); expression = new JRDesignExpression(); expression.setValueClass(java.lang.String.class); expression.setText("$P{param4}"«»); textField.setExpression(expression); band.addElement(textField); jd.setColumnHeader(band); //Detail band = new JRDesignBand(); band.setHeight(55); textField = new JRDesignTextField(); textField.setBlankWhenNull(true); textField.setWidth(107); textField.setHeight(55); textField.setX(0); textField.setY(0); textField.setRemoveLineWhenBlank(true); textField.setHorizontalAlignment(JRAlignment.HORIZONTAL_ALIGN_CENTER); textField.setVerticalAlignment(JRAlignment.VERTICAL_ALIGN_MIDDLE); textField.setStyle(normalStyle); textField.setBold(true); expression = new JRDesignExpression(); expression.setValueClass(java.lang.Integer.class); expression.setText("$F{Vac}"«»); textField.setExpression(expression); band.addElement(textField); textField = new JRDesignTextField(); textField.setBlankWhenNull(true); textField.setWidth(107); textField.setHeight(55); textField.setX(107); textField.setY(0); textField.setRemoveLineWhenBlank(true); textField.setHorizontalAlignment(JRAlignment.HORIZONTAL_ALIGN_CENTER); textField.setVerticalAlignment(JRAlignment.VERTICAL_ALIGN_MIDDLE); textField.setStyle(normalStyle); textField.setBold(true); expression = new JRDesignExpression(); expression.setValueClass(java.lang.Integer.class); expression.setText("$F{Vbc}"«»); textField.setExpression(expression); band.addElement(textField); textField = new JRDesignTextField(); textField.setBlankWhenNull(true); textField.setWidth(107); textField.setHeight(55); textField.setX(214); textField.setY(0); textField.setRemoveLineWhenBlank(true); textField.setHorizontalAlignment(JRAlignment.HORIZONTAL_ALIGN_CENTER); textField.setVerticalAlignment(JRAlignment.VERTICAL_ALIGN_MIDDLE); textField.setStyle(normalStyle); textField.setBold(true); expression = new JRDesignExpression(); expression.setValueClass(java.lang.Integer.class); expression.setText("$F{Vca}"«»); textField.setExpression(expression); band.addElement(textField); textField = new JRDesignTextField(); textField.setBlankWhenNull(true); textField.setWidth(107); textField.setHeight(55); textField.setX(321); textField.setY(0); textField.setRemoveLineWhenBlank(true); textField.setHorizontalAlignment(JRAlignment.HORIZONTAL_ALIGN_CENTER); textField.setVerticalAlignment(JRAlignment.VERTICAL_ALIGN_MIDDLE); textField.setStyle(normalStyle); textField.setBold(true); expression = new JRDesignExpression(); expression.setValueClass(java.lang.Integer.class); expression.setText("$F{Ica}"«»); textField.setExpression(expression); band.addElement(textField); textField = new JRDesignTextField(); textField.setBlankWhenNull(true); textField.setWidth(107); textField.setHeight(55); textField.setX(428); textField.setY(0); textField.setRemoveLineWhenBlank(true); textField.setHorizontalAlignment(JRAlignment.HORIZONTAL_ALIGN_CENTER); textField.setVerticalAlignment(JRAlignment.VERTICAL_ALIGN_MIDDLE); textField.setStyle(normalStyle); textField.setBold(true); expression = new JRDesignExpression(); expression.setValueClass(java.lang.Integer.class); expression.setText("$F{Iac}"«»); textField.setExpression(expression); band.addElement(textField); jd.getExpressions(); int s = jd.getFieldsList().size(); List f = jd.getFieldsList(); int sz = f.size(); f.get(0); jd.setDetail(band); //Column footer band = new JRDesignBand(); band.setHeight(0); jd.setColumnFooter(band); //Page footer band = new JRDesignBand(); band.setHeight(0); jd.setPageFooter(band); //Summary band = new JRDesignBand(); band.setHeight(0); jd.setSummary(band); }catch(JRException ex){ throw new JRException(ex.getMessage());//If the throw exception throws catch it here } return jd; } } As my fields will be dynamic and being selected by each user so I put condition on my field to load only existed fields. But to test it for the first time I load all fields but nothing showed at Detail bands!!!!! Where I am doing wrong????? Teodor I do appreciate you to help one more time and make things clear to me. I am so looking forward to your reply, Thank you. Pegah
  9. Hello Teodor, I searched in forums for making dynamic report and found that I can use the examples in /demo/samples/noxmldesign package as you mentioned. But one thing I could not understand is 1-What would be "args" in main method? 2-About the task name can you explain more. I appreciate your concern and would be so great if you make me clear. Thank you, Pegah
  10. Hi vinays84, Thanks for your help.It works:P
  11. Hello all, I am working with iReport2.0.1 and wanna send query as a string to iReport.So I define a string parameter and set the query as its default value: "select * from test" as a default value for $P{dbQuery},but the problem is the iReport database could not understand String parameter and give me an exception!!!!! It says : {You have an error in your sql syntax;check the manual that corespondens to your SQL server version for the right syntax to use near "select * from test" !!!} Can anyone please tell me where did I wrong??????? Thank you, Pegah
  12. Hi all again, After searching and working on my problem a lot I found a way that solved most of my problem. It is not a correct solution but at least I can get a better look for my reports. I did the report for the web application so these two lines of code has to add to the Servlet. exporterHTML.setParameter(JRHtmlExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS,Boolean.TRUE); exporterHTML.setParameter(JRHtmlExporterParameter.BETWEEN_PAGES_HTML,"<div style='page-break-after:always'></div>" ); I hope Jasper group team could solve this problem in the next version. Thank you. Pegah
  13. Hi all again, After searching and working on my problem a lot I found a way that solved most of my problem. It is not a correct solution but at least I can get a better look for my reports. I did the report for the web application so these two lines of code has to add to the Servlet. exporterHTML.setParameter(JRHtmlExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS,Boolean.TRUE); exporterHTML.setParameter(JRHtmlExporterParameter.BETWEEN_PAGES_HTML,"<div style='page-break-after:always'></div>" ); I hope Jasper group team could solve this problem in the next version. Thank you. Pegah
  14. Hello all; I posted this problem in iReport Forum too but seems no one could help me. Please got through this link where I report a bug with the complete explanation. Please consider my post and help me.I am so confused :blink: http://jasperforge.org/sf/go/artf2303?nav=1
  15. Hi again, This is the link I reported a bug with its details explained.I do need your help and would be so glad if somebody at least read my post and reply it. http://jasperforge.org/sf/go/artf2303?nav=1
×
×
  • Create New...