Jump to content
Changes to the Jaspersoft community edition download ×

augarte

Members
  • Posts

    270
  • 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 augarte

  1. Hi, I'm trying to create a report using an excel datasource as subreport connection. If I create the subreport itself with the excel datasource it works ok. It has a numeric type column "COLUMN_2" defined as java.lang.Float. I would like to attach the files but don't find where can I do it. After that, I've created the main report with an empty datasource and a subreport connection defined as follows: new net.sf.jasperreports.engine.data.JRXlsxDataSource("...\SubreportDataSource.xlsx") When I try to preview the main report I get the following error: Error filling print... net.sf.jasperreports.engine.JRException: Unable to get value for field 'COLUMN_2' of class 'java.lang.Float' net.sf.jasperreports.engine.JRRuntimeException: net.sf.jasperreports.engine.JRException: Unable to get value for field 'COLUMN_2' of class 'java.lang.Float' at net.sf.jasperreports.engine.fill.JRFillSubreport.prepare(JRFillSubreport.java:782) at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:331) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:384) at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:358) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2046) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:778) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:288) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:151) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:909) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:841) at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:88) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:653) at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:569) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:915) at com.jaspersoft.ireport.designer.compiler.IReportCompiler.run(IReportCompiler.java:928) at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:572) at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:997) Caused by: net.sf.jasperreports.engine.JRException: Unable to get value for field 'COLUMN_2' of class 'java.lang.Float' at net.sf.jasperreports.engine.data.JRXlsxDataSource.getFieldValue(JRXlsxDataSource.java:253) at net.sf.jasperreports.engine.fill.JRFillDataset.setOldValues(JRFillDataset.java:1331) at net.sf.jasperreports.engine.fill.JRFillDataset.next(JRFillDataset.java:1232) at net.sf.jasperreports.engine.fill.JRFillDataset.next(JRFillDataset.java:1208) at net.sf.jasperreports.engine.fill.JRBaseFiller.next(JRBaseFiller.java:1554) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:149) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:909) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:841) at net.sf.jasperreports.engine.fill.JRFillSubreport.fillSubreport(JRFillSubreport.java:655) at net.sf.jasperreports.engine.fill.JRSubreportRunnable.run(JRSubreportRunnable.java:59) at net.sf.jasperreports.engine.fill.AbstractThreadSubreportRunner.run(AbstractThreadSubreportRunner.java:203) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:724) Caused by: java.lang.IllegalStateException: Cannot get a numeric value from a text cell at org.apache.poi.xssf.usermodel.XSSFCell.typeMismatch(XSSFCell.java:843) at org.apache.poi.xssf.usermodel.XSSFCell.getNumericCellValue(XSSFCell.java:208) at net.sf.jasperreports.engine.data.JRXlsxDataSource.getFieldValue(JRXlsxDataSource.java:231) ... 13 more Print not filled. Try to use an EmptyDataSource... I've been reading about possible causes of the error and didn't find a solution. I guess the problem comes because the connection defined in the first case and the connection I'm passing to the subreport have configured different numeric formats and one of them is reading it as number and the other one as text. Anyway, don't know how to solve it. Could anybody help be? Thanks in advance and best regards.
  2. Hi, I was wrong, you have to set the expression in "Initial Value Expression" and not in "Variable expression". By the way, your expression is wrong. As rownum is Integer type, the expression should be set as follows: $F{rownum}== 1 ?$F{sum}:new Double("0") Hope this helps. Regards, Aitor
  3. Hi, If you want to compare a field with a parameter, I think both have to be the same type, you can't compare a String field with a Date parameter. In your case, you should put the following in the print when expression: $F{fromdate}.equals($P{startdate}.toString()) ? Boolean.TRUE : Boolean.FALSE But take into account that in this case, if fromdate is different to startdate, nothing will be printed, and I guess you want to print "0". In this case, you should create a variable (Double type), and put the following in the "Variable Expression": $F{fromdate}.equals($P{startdate}.toString()) ? $F{Sum} : new Double("0") Hope this helps, Regards Aitor
  4. Hi, I've never used it but I think this is what you need: https://www.jaspersoft.com/analysis Hope this helps. Regards, Aitor
  5. Hi, It's difficult to know what happens with this explanation. What I see is that you have the same data in the first and second sheet but don't know how have you created the report and how you receive the data from your datasource. Could you give us more information? Regards
  6. Hi, If you add to the classpath the jar file that contains the class "net.sourceforge.jtds.jdbc.Driver", iReport should recognize it. For adding it, go to "Tools-->Options-->Classpath-->Add JAR"
  7. Hi, I have a problem in my application. I have a text field with the following value: "<b>Developments</b> in "+$F{prt} + " ("+$F{iniDat}+" to "+$F{finDat}+")" I use "html markup" in order to show "Developments" word in bold and the rest as normal text (no bold) When I preview the pdf file from iReport it works ok and the result is the one I want (in both, jasper and pdf files). The problem comes when I export it from my application (java code that uses JRPdfExporter), because the text that was suposed to be shown with bold font is shown as normal text. I guess it is a exporter property that iReport has inherited and I need to add it to my code, but I can't find out the property I need to add. The iReport/jasperreports version I'm using is the 5.1.0. Any help? Kind regards, Aitor
  8. Hi, It seems you don't have java installed in your computer. You have to install it, and then in your ireport installation, inside "etc" folder you can see that you have a "ireport.conf" file, where you can define a "jdkhome" property, which is the directory where you have installed java. Hope this helps. Regards
  9. Hi Gaizka, I've tried to set it through iReport but didn't work for me. Im my case, as I export the reports through java, I have a exporter method, to which I have added the both properties mentioned in the previous post: public void ExpToPdf (String Nam, List JasLst) /************************************************************************************************/ { try{ JRPdfExporter PdfExporter = new JRPdfExporter (); PdfExporter.setParameter (JRExporterParameter.JASPER_PRINT_LIST, JasLst); PdfExporter.setParameter (JRExporterParameter.OUTPUT_FILE_NAME, Nam); PdfExporter.setParameter (JRPdfExporterParameter.METADATA_AUTHOR, "Aitor Ugarte"); PdfExporter.setParameter (JRPdfExporterParameter.METADATA_CREATOR,"Ugarte Aitor"); PdfExporter.exportReport (); } catch (Exception e){ e.printStackTrace(); } } This worked for me, don't know if it is a valid solution for you. Hope this helps. Regards, Aitor
  10. Hi Robert, I don't understand what you mean exactly with subdatasets... are you using subreports? In your first post you say that each detail contains 1 table of a dataset. Aren't you able to create a variable for each dataset and then use the same condition (with the corresponding variable in each detail band) to hide/show the band? May be attaching your jrxml will be easier to understand your problem and help you. Regards
  11. Not sure if it is the best one, but a possible solution could be the following one: You create a Variable, which counts the number of elements you have in your query. For example, imagine that you retrieve the field "Fld" in your query. You can create a variable with the following properties: - Name: NumRow - Calculation: Count - Variable Expression: $F{Fld} This variable will calculate the number of rows you have in your query, if it is 0, it means there is not any row so you can hide the band. In the "Print When Expression" you should set something like: $V{NumRow} != 0 ? Boolean.TRUE : Boolean.FALSE Hope this helps. Regards
  12. Hi, You can use "Print When Expression" to hide report bands. You have to get in a parameter of field if your query returns and empty set and set an expression as follows: $F{data} != null ? Boolean.TRUE : Boolean.FALSE In this case, if the field "data" is null the band in which you set the expression will be hided, otherwise it will be shown. Hope this helps, Regards
  13. Hi Gaizka, Not sure how it works because I've never used it but it seems that this is what you want: http://jasperreports.sourceforge.net/api/net/sf/jasperreports/engine/export/JRPdfExporterParameter.html#METADATA_AUTHOR Maybe you can directly set the property and its value in iReport: net.sf.jasperreports.engine.export.JRPdfExporterParameter.METADATA_AUTHOR There is a similar property METADATA_CREATOR. I really don't know which one is the difference between them but maybe you can use any of them to achieve what you want. Hope this help. Regards, Aitor
  14. Hi, If I understood well you have all the images stored in "D:NewWorkspace.metadata.pluginsorg.eclipse.wst.server.coretmp0wtpwebappsloginhiresharedphotoprofile" Then, you have the names of the photos in database, so I guess you are retrieving this value as a field. For example: $F{Img} If this is right, you only have to add an image and set the following in you image expression: "D:NewWorkspace.metadata.pluginsorg.eclipse.wst.server.coretmp0wtpwebappsloginhiresharedphotoprofile"+$F{Img} Hope this helps. Regards
  15. Hi, I'm trying to set sheet names for excel reports. In this case I have an excel file with two sheets and I try to set the sheet names as follows: String [] abcd = new String [2];abcd [0] = "BBVA";abcd [1] = "CO13";exporterXLS.setParameter(JRXlsAbstractExporterParameter.SHEET_NAMES, abcd); As a result, the first sheet is getting the name correctly ("BBVA"), but the name of the second sheet is "Page 1". Am I doing something wrong? The jasper version I'm using is 3.7.1. Thanks in advance. Best regards
  16. Hi, I think when you use parameters in a query you need to use the following notation: $P!{parameter1}. At least, in the reports I've done till now I have used parameters as mentioned. So you should set your query as follows: SELECT DATE FROM TABLE WHERE EXTRACT(YEAR FROM DATE) = EXTRACT (YEAR FROM CURREN_DATE) AND EXTRACT (MONTH FROM DATE) = EXTRACT (MONTH FROM $P!{parameter1}) Hope this helps. Regards
  17. Do you get some more information if you put a try/catch block and print all the stack of the exception? Try with this: protected byte[] export(JasperPrint jasperPrint, JRExporter exporter) throws JRException { ByteArrayOutputStream baos = null; try{ baos = new ByteArrayOutputStream(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baos); exporter.exportReport(); } catch (Exception e) { e.printStackTrace(); } return baos.toByteArray(); }
  18. Hi, The decimal separator depends on the "Locale" of your report. You have two options: - If you are generatting the report from iReport, you can change your "Report Locale". Go to "Tools->Options->Compilation and Execution" and choose the required locale. - If you are generating the report from java, you can add a parameter as follows: Map parameters = new HashMap(); parameters.put(JRParameter.REPORT_LOCALE, Locale.US); JasperReport report = JasperCompileManager.compileReport(reportPath); JasperPrint print = JasperFillManager.fillReport(report, parameters, ConnrsProyectos); Be carefull with this because it might change other properties (date format and so on... ), aside from the thousand separator. What I don't know is if exists any Locale that sets "-" as thousand separator. Hope this helps. Regards
  19. Hi, In the report Properties there is an option "Language" (check the attachment). I think your poblem is that you have selected "Groovy" instead of Java. Try changing this property and setting it as Java. This might solve your problem. Regards
  20. In thas case you need to get the connection to the database first. This link can help you: http://www.roseindia.net/tutorial/java/jdbc/jdbcdrivermanager.html Then, the code should be very similar to the one I have posted. The only modification is the call to fillReport function: JasperPrint Prn = JasperFillManager.fillReport (Rep, new HashMap (), Con); As you can see the only modification is in the last parameter "Con" (java.sql.Conneciton type), which is the connection to your database, and you can get it in the link I have put above. Hope this helps. Regards
  21. Hi, The code depends on the datasource you want to use for generating the report, this one is an example that shows how to create a pdf file having a xml datasource and a jrxml file: File f = new File ("XmlDataSource.xml"); JRXmlDataSource JprXmlDsr = new JRXmlDataSource (f, "DataList/Line"); /* Compile the template */ JasperReport Rep = JasperCompileManager.compileReport ("MyReport.jrxml"); /* Create the JasperPrint object with the template and the data */ JasperPrint Prn = JasperFillManager.fillReport (Rep, new HashMap (), JprXmlDsr); /* Export the report to pdf format if needed*/ JasperExportManager.exportReportToPdfFile (Prn, "MyReport.pdf"); About the jar files you need, there is a post that tells the necessary ones : http://community.jaspersoft.com/questions/529175/required-jar-files-compilingfillingexporting About passing parameters to the report, you can see that in the code I have written above there is a HashMap in the call to "fillReport" function. You can add all the parameters you need in this HashMap. For example: HashMap map = new HashMap ();HashMap.put ("ParamName", paramValue); I'm not sure if it is possible to do the las thing you want to do. If I'm not wrong, you want to know how many parameters do you have in your jrmxl report. The only way I know would be parsing the jrxml file but don't know if there is any other option. Hope this helps. Regards
  22. Hi, Can you check if each of the JasperPrint objects is generated correctly? Do yo have any Image in your reports? It seems it doesn't know how to read an image. In this link says that this problem was solved setting "Blank" in image "On Error Type" property. Can you try this? http://www.coderanch.com/t/64171/open-source/Jasper-Report-JRException-Image-read Hope this helps. Regards
  23. You can have a loop in which you generate differente jasperPrint objects and then export the list of jasperPrint objetcs to a pdf file: ArrayList JasPrnLst = new ArrayList(); try { for (int Inx=0; Inx < NumRep; Inx++) { /* Get the data source (xml file) */ File f = new File (args [inx+NumRep+1]); System.out.println (f); JRXmlDataSource JprXmlDsr = new JRXmlDataSource (f, "DataList/Line"); /* Compile the template */ JasperReport Rep = JasperCompileManager.compileReport (args[inx+1]); /* Create the JasperPrint object with the template and the data */ JasPrnLst.add (JasperFillManager.fillReport (Rep, new HashMap (), JprXmlDsr)); } JRPdfExporter PdfExporter = new JRPdfExporter (); PdfExporter.setParameter (JRExporterParameter.JASPER_PRINT_LIST, JasPrnLst); PdfExporter.setParameter (JRExporterParameter.OUTPUT_FILE_NAME, args[NumRep*2+1]); PdfExporter.exportReport (); In the showed example what I do is to generate a jasperPrint in each iteration with a different datasource and a different jrxml template. In your case it should be something similar but using the same templates in all the iterations and only changing the value of the parameter. Hope this helps. Regards
  24. Your are using an xml file as datasource right? If so, could you also attach the file in order to test your report?
×
×
  • Create New...