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

slow

Members
  • Posts

    268
  • Joined

  • Last visited

 Content Type 

Profiles

Forum

Events

Featured Visualizations

Knowledge Base

Documentation (PDF Downloads)

Blog

Documentation (Test Area)

Documentation

Dr. Jaspersoft Webinar Series

Downloads

Everything posted by slow

  1. hi rajuchacha007 :) I find some indications that you give to us very interesting... so I try to understand how they work reporting to you what I find (to be fair :) ) joda-time is an interesting library... to use it simply: --put the joda-time.jar in a directory. --from Option-->classpath-->add jar: add this jar --create a simple report --create a variable (we call it "now") of java.util.Date type... set the expression as " new Date() " --click on the report main node, the in the properties on the "import" field and add: org.joda.time.DateTime --define a new variable (we cal it "ms") that represent millisecond, of type Long, set the expression as: new Long((new DateTime($V{now})).millisOfSecond().getMillis()) now add to the report two textfiled, one for the variable "now" (type Date), now for the variable "ms", type Long. I use to set a connection to a Orable DB setting the query to "select 1 from dual". you can try to use a empty data source with 2 or 10 records... if you use more and more record you can see how the variables show different values on differend rows. I used a simple test to show the use of joda-time, maybe it'snt the method you want... but, it works, so you can choose the method you prefer to show your data. give me feedback... and good work :) _________________________________________ if you like it... give me KARMA points please! : ) _________________________________________ listening: CSI - Io Sto Bene
  2. in a similar task solved time ago I passed to the report a parameter that specify the export format I'm generating (I produced several report format from the same jrxml source with a servlet) whit this parameter (XLS, PDF, CSV etc...) I modify the report layout and, if it's too hard to manage then I use it to switch through several templates ( a solution that I don't like but sometimes it's necessary because of the "rigid" jasperreport model) Maybe can be useful intercept the exporting format of the jrxml and using it to manipulate the layout without passing it as a parameter... but they are similar methods.
  3. in the variable definition you have set a reset type of "page"... are you sure to want it? the other things seem to be correct... and the definition of a sum variable is a very simple task...
  4. try to use this simple trick (i used it...) in the detail band set the "print when expression" as: new Boolean($V{REPORT_COUNT}.intValue()<=5) 5 (or the fixed value) can be replaced with a parameter if you prefer. give us feedback... _________________________________________ if it works... give me KARMA points please! : ) _________________________________________ listening: Stereolab- Emperor Tomato Ketchup Post Edited by slow at 08/18/2010 12:49
  5. you need only one variable that makes an average of worked hours. suppose we call it $V{avg_hours} then, if you want to show the difference between the single employee hours ($F{HOURS}) and this average value ($V{avg_hours}), create a textfield with BigDecimal type putting this expression (equal to the expression you use) $F{HOURS}.subtract($V{avg_hours} ) then set the evaluation time to AUTO. in this way it works. when you set the evaluation time to NOW (as you make) simply the JasperReport core makes a difference between the value of employee hours and the average calculated at this point of report... so for the first one the average is 3... 3-3 =0 for the second is 3+6=9 /2=4,5 6-4,5=1,5 and so on... give us feedback... ________________________________________ if it works... give me KARMA points please! : ) _________________________________________ listening: Stereolab- Emperor Tomato Ketch Post Edited by slow at 08/18/2010 09:59
  6. there is certainly other element incorrect but it is not the expression that you asked to modify. the form of the suggested expression works perfectly. have you tried to analize all elements involved in the textfield printing? listening Lamb - One
  7. try to use this expression in the pattern field of your bigDecimal textfield: #,##0.##;-#,##0.## give us feedback... _________________________________________ if it works... give me KARMA points please! : ) _________________________________________ listening: Lamb - Gabriel Post Edited by slow at 08/19/2010 06:59
  8. try this: new Integer($F{FIELD1}==null?0:($F{FIELD1}.intValue()>=9?1:0)) or in a better form: new Integer($F{FIELD1}==null||$F{FIELD1}.intValue()<9?0:1) give us feedbak. _________________________________________ if it works... give me KARMA points please! : ) _________________________________________ listening: Pixies - Where is my Mind (Fight Club Soundtrack)
  9. can you be more clear giving us more details about the date field format? (it is a Date, a Timestamp, a String etc ?) (is the date you write about the sales_positions_vpo_dbeleg field?) Post Edited by slow at 08/17/2010 12:53
  10. in the TOTAL_SQUID_QUANTITY variable definition you try to sum the squidQuantity field... but this field is defined (see the field declarations) as a String field... so this is the reason of your casting error. try to set squidQuantity type to double or float setting TOTAL_SQUID_QUANTITY type to the same one. give us feedback. _________________________________________ if it works... give me KARMA points please! : ) _________________________________________ listening: Underworld - Rez/Cowgirl
  11. Unfortunately, as far as I know, Working in iReport horizontally, thit this I mean creating very large horizontal dynamic structures is impossible unless you create report template programmatically using a programming language (like Java). after all is as if you created a table structure in html with a jsp/asp/php etc etc ... is not impossible, just a little boring.
  12. I'm talking about copy it to the "pattern expression", the 4° row in the text field properties editor on the right side of your Ireport standard layout when you click on the Date textfiled you want to format and show...
  13. use the expression class set to java.util.Date but use this pattern (copy it in the texfield) : yyyy-MM-dd KK:mm:ss a for the extra page I think there is a bad layout organization... try to set it better. give us feedback. (next time try to choose a better title maybe with some extra letters...) ________________________________________________________ if it works (and IT WORKS)... give me KARMA points please! : ) ________________________________________________________ listening: A SERBIAN FILM (SRPSKI FILM) - Soundtrack Post Edited by slow at 07/26/2010 09:03
  14. Unfortunately I work for a large company, "very jealous" of its code, that will not let me "spread it. I believe that studying the ideas I gave you can get a good report without much effort... In any case here there is a great forum that will be able to help you.
  15. if you read here http://jasperreports.sourceforge.net/api/net/sf/jasperreports/engine/type/RotationEnum.html and here http://jasperreports.sourceforge.net/sample.reference/rotation/index.html seems that it's impossible. if you want... give me karma points for the bad news :)
  16. Uhm... i think the best way is to work with simple report structure, without columns (200 columns?), crosstab or table... I suggest to create a report (maybe programmatically) with 200 contiguous cells (you can create 2-3 cell of 100-150 pixel width and then add the others generating the code that prints the XML portion to append the other cells with the appropriate position with Java (any programming language is good to do this) In the cell expression I suggest to set an expression like: getStringAt($F{yourVeryLongString}, position) where postionis a number from 0 to 199 (1 to 200), that is different from each cell. and getStringAt(String, int) is a simple Java method that split the input string (using che comma char) returning one at "position" position, or "" (blank) if there isn't a value at this position. putting this method in scriplet or in a Java class (in a jar library) in the IReport classpath. all this cell must be placed in the detail band. pay attention to the perfect position of the cell, without pixel gap between cell borders, so you can extract a perfect excel file. if you need more performance,than you may try to optimize you report trying to work with a function that creates a String array only one time, passing it to the cell expression to avoid the splitting of the mega-string 200 times per report-row! I made 7-8 months ago a similiar work for a multipage excel report with a fixed number of column (i remember something like 115 columns)... but doing it for 50, 100, or 1000 columns is the same. _________________________________________ if you like it... give me KARMA points please! : ) _________________________________________ listening: Nine Inch Nails Survalism "You see your world on fire Don't try to act surprised We did just what you told us Lost our faith along the way and found ourselves believing your lies" (t.r.) Post Edited by slow at 07/21/2010 09:37
  17. is there a max number of the words in a single row ( a superior limit)? must all the words in a row be printed in a schema without empty spaces (empty columns) ?
  18. It's possible using a library you set in you classpath that uses a class that converts numbers to words... or a report scriplet with the same methods... I think also this is a java-forum retated question... not an iReport-forum one... but... here to you a class that makes what you want... simply include it in a jar and put this jar in your IReport classpath or put the class in a scriplet: public class NumberToWords{ private static final String[] tens = { "", " ten", " twenty", " thirty", " forty", " fifty", " sixty", " seventy", " eighty", " ninety" }; private static final String[] numbers = { "", " one", " two", " three", " four", " five", " six", " seven", " eight", " nine", " ten", " eleven", " twelve", " thirteen", " fourteen", " fifteen", " sixteen", " seventeen", " eighteen", " nineteen" }; private static String convertNumberLessThanOneThousand(int number) { String rest; if (number % 100 < 20){ rest = numbers[number % 100]; number /= 100; } else { rest = numbers[number % 10]; number /= 10; rest = tens[number % 10] + rest; number /= 10; } if (number == 0) return rest; return numbers[number] + " hundred" + rest; } public static String convertNumber(long number) { if (number == 0) { return "zero"; } String snumber = Long.toString(number); String zeroMask = "000000000000"; DecimalFormat df = new DecimalFormat(zeroMask); snumber = df.format(number); int billions = Integer.parseInt(snumber.substring(0,3)); int millions = Integer.parseInt(snumber.substring(3,6)); int hundredThousands = Integer.parseInt(snumber.substring(6,9)); int thousands = Integer.parseInt(snumber.substring(9,12)); String billionsString; switch (billions) { case 0: billionsString = ""; break; case 1 : billionsString = convertNumberLessThanOneThousand(billions) + " billion "; break; default : billionsString = convertNumberLessThanOneThousand(billions) + " billion "; } String result = billionsString; String millionsString; switch (millions) { case 0: millionsString = ""; break; case 1 : millionsString = convertNumberLessThanOneThousand(millions) + " million "; break; default : millionsString = convertNumberLessThanOneThousand(millions) + " million "; } result = result + millionsString; String hundredThousandsString; switch (hundredThousands) { case 0: hundredThousandsString = ""; break; case 1 : hundredThousandsString = "one thousand "; break; default : hundredThousandsString = convertNumberLessThanOneThousand(hundredThousands) + " thousand "; } result = result + hundredThousandsString; String thousandString; thousandString = convertNumberLessThanOneThousand(thousands); result = result + thousandString; return result.replaceAll("^\s+", "").replaceAll("\b\s{2,}\b", " "); } to use the conversion set the String textField expression as: (yourclassname).convertNumber($F{yourNumericFiledName}.longValue()) or if you use a scriplet: $P{REPORT_SCRIPTLET}.convertNumber($F{yourNumericFiledName}.longValue()) _________________________________________ if you like it... give me KARMA points please! : ) _________________________________________ listening: Nine Inch Nails Only "Now I'm somewhere I am not supposed to be And I can see things I know I really shouldn't see And now I know why now, now I know why Things aren't as pretty on the inside" (t.r.) Post Edited by slow at 07/21/2010 08:09
  19. if you modify only the "presentation" layer... or a textfield you have no issue to solve. if you make some modification to the field coming from the db, maybe some problems can happen... but i think, (I'm sure) you have modified only the textfield that show the code using the format "("+yourFieldName.intValue()+")" so it's all ok. thanks for karma... listening Lamb - Gabriel
  20. if your field is an Integer field... then, you must change the textfield to a String type and set the expressione like: "("+yourFieldName.intValue()+")" if your field is a String field... then simply set the expression as: "("+yourFieldName+")" if it is in a different format, post its format so I can help you in a better way. give us feedback :) _________________________________________ if it works... give me KARMA points please! : ) _________________________________________ listening: Underworld - Rez/Cowgirl Post Edited by slow at 07/20/2010 08:35
  21. I think there is no way to obtain a recursive and generic query with simple sql code... so you must replicate your code to obtain a right level and show your data. you can study postgres technique to obtain hierarchical query if you prefer... but , if you know the max level deep I think this is the best generic way to do it. good report :)
  22. Yes... I have created a simple test query with one sum (and obviously a GROUB BY clause)... and it works. have you tried to use a different version of iReport? what version do you use?
  23. what you are talking about is a hierarchical query/report. what database you use? each database uses sometimes custom method to obtain hierarchical results... this is the example with oracle DB: (suppose the second table is called tmp_sub, whit column name "cod | sub") (I tested it on my local Oracle inatallation with this name :) ) you can use : select lpad(' ',2*(level-1)) || sub , level from tmp_sub start with cod = '2110000000000150' connect by prior sub = cod; imagine to cycle the '2110000000000150' selecting it from a main report and executing this query in subreport, using the "level" value to pad the obtained results. you obtain this values: 2110230000025220 1 2110230000025210 2 2110010000012450 3 2110010000012850 3 2110230000025250 3 2110230000025270 2 2110230000028850 1 another general solution (i prefer) is using the join clause: SELECT ts1.cod, ts1.sub AS lev1, ts2.sub as lev2, ts3.sub as lev3, ts4.sub as lev4 FROM tmp_sub ts1 LEFT JOIN tmp_sub ts2 ON ts2.cod = ts1.sub LEFT JOIN tmp_sub ts3 ON ts3.cod = ts2.sub LEFT JOIN tmp_sub ts4 ON ts4.cod = ts3.sub WHERE ts1.cod not in (select distinct t.sub from tmp_sub t) order by 1,2,3,4,5 in this case you obtain this results: COD LEV1 LEV2 LEV3 LEV4 2110000000000150 2110230000025220 2110230000025210 2110010000012450 2110000000000150 2110230000025220 2110230000025210 2110010000012850 2110000000000150 2110230000025220 2110230000025210 2110230000025250 2110000000000150 2110230000025220 2110230000025270 2110000000000150 2110230000028850 now you can use groups to print the obtained values, avoiding to print the repeated ones. if you have more and more levels of parent/child relationship in your table, then you can add more "join" relationships in your query. I tested and used it and it works well. Give us your feedback...and: _________________________________________ if you like it... give me KARMA points please! : ) _________________________________________ listening: Ravel - Bolero
  24. uhm... I'll try to explain to you two tecniques to solve your issue... 1) the first, if you can, is to pass the sql-code portion you want append to query directly as parameter... so instead to pass a non-null parmPK parameter... you can pass a sql code like: where table2.PK=avalue (call this parameter extra_sql) and defining your query as: select <some columns> from table1 join table2 on table1.FK=table2.PK $P!{sql_extra} (note che $P!{} syntax) if you have a null parmPK simply pass "" (empty string) to sql_extra. 2) the second tecnique is similar but is useful when you can't pass programmatically sql-code to your report... when the parameter values are passed from a human so extra sql code must be calculated in the report logic. you can define a parameter sql_extra that contains this logic: ($P{parmPK} == null ? "" : "where table2.PK="+$P{parmPK}.intValue()) (remember to remove the check that creates a prompt for this parameter each time you run the report and define this parameter after the parmPK definition) and the define your query as: select <some columns> from table1 join table2 on table1.FK=table2.PK $P!{sql_extra} such the previous way. give us a feedback...and _________________________________________ if it works... give me KARMA points please! : ) _________________________________________ listening: MUSICA NUDA - Sacrifice "But suddenly you needed freedom You felt the need to break free You started drowning in your sorrow You didn't wanna know I had the key" (a.)
×
×
  • Create New...