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

gal64

Members
  • Posts

    11
  • 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

Posts posted by gal64

  1. Hello, everybody,

    I do some Excel-Exports with JasperReports 5.5.0.  The report contaons some Date-Fields.

    The JasperPrint-Object will be created, but the JRXlsxExporter.export-Method fails with the following error:

     

     

    java.lang.NullPointerException
    at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:768)
    at java.util.Calendar.setWeekCountData(Calendar.java:2451)
    at java.util.Calendar.<init>(Calendar.java:937)
    at java.util.GregorianCalendar.<init>(GregorianCalendar.java:574)
    at net.sf.jasperreports.engine.util.JRDataUtils.getExcelSerialDayNumber(JRDataUtils.java:90)
    at net.sf.jasperreports.engine.export.ooxml.JRXlsxExporter$1.handle(JRXlsxExporter.java:1368)
    at net.sf.jasperreports.engine.export.data.DateTextValue.handle(DateTextValue.java:59)
    at net.sf.jasperreports.engine.export.ooxml.JRXlsxExporter.exportText(JRXlsxExporter.java:1407)
    at net.sf.jasperreports.engine.export.JRXlsAbstractExporter.exportPage(JRXlsAbstractExporter.java:1201)
    at net.sf.jasperreports.engine.export.JRXlsAbstractExporter.exportReportToStream(JRXlsAbstractExporter.java:969)
    at net.sf.jasperreports.engine.export.JRXlsAbstractExporter.exportReport(JRXlsAbstractExporter.java:697)

     

     

    With JEcelApiExporter all works fine with the same data, but I need JRXlsxExporter, because we need xlsx.

     

    Has anyone some suggestions about that?

     

    Thank you very much and I wish you happy christmas and happy new year, Gerhard

  2. Hello,

    I have a problem with printing a report, which doesn't fit to one page.
    The size of the report can vary, but let's take the example I have, width 1800, height 150.
    Because it is much wider than high, I turn to Landscape.
    The whole report must fit to one page, so I try to configure this in the printing dialog. The JasperViewer shows the report correct, so as I want it.
    (Screenshot 1)
    But when I try to print it out, some columns are cut off. (Screenshot 2/3)
    This is the code:

    final PrinterJob pJob = PrinterJob.getPrinterJob();
    pJob.setJobName("Some Name");
    final PrintService service = pJob.getPrintService();
    final PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet();
    printRequestAttributeSet.add(OrientationRequested.LANDSCAPE);
    printRequestAttributeSet.add(new NumberUp(1));
    final JRPrintServiceExporter exporter = new JRPrintServiceExporter();
    exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
    exporter.setParameter(JRPrintServiceExporterParameter.PRINT_REQUEST_ATTRIBUTE_SET, printRequestAttributeSet);
    exporter.setParameter(JRPrintServiceExporterParameter.PRINT_SERVICE_ATTRIBUTE_SET, service.getAttributes());
    exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PAGE_DIALOG, Boolean.FALSE);
    exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PRINT_DIALOG, Boolean.TRUE);
    exporter.exportReport();

    As I told, jasperPrint is correct, I see this in the Viewer.

    Another idea I had was to create a PDF and print that.
    The PDF will be correct, and when I save it and print the saved file, it's ok.
    But I don't want to save it and open it with a PDF-Viewer, I want to print directly.
    I tried this:

    ByteArrayOutputStream outstream = new ByteArrayOutputStream();
    JasperExportManager.exportReportToPdfStream(jasperPrint, outstream);
    byte[] buffer = outstream.toByteArray();
    outstream.close();
    InputStream instream = new ByteArrayInputStream(buffer);
    final PrinterJob pJob = PrinterJob.getPrinterJob();
    pJob.setJobName("Some Name");
    final PrintService service = pJob.getPrintService();
    final PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet();
    printRequestAttributeSet.add(OrientationRequested.LANDSCAPE);
    printRequestAttributeSet.add(new NumberUp(1));
    final JRPrintServiceExporter exporter = new JRPrintServiceExporter();
    exporter.setParameter(JRExporterParameter.INPUT_STREAM, instream);
    exporter.setParameter(JRPrintServiceExporterParameter.PRINT_REQUEST_ATTRIBUTE_SET, printRequestAttributeSet);
    exporter.setParameter(JRPrintServiceExporterParameter.PRINT_SERVICE_ATTRIBUTE_SET, service.getAttributes());
    exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PAGE_DIALOG, Boolean.FALSE);
    exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PRINT_DIALOG, Boolean.TRUE);
    exporter.exportReport();

    But this leads to the error:
    net.sf.jasperreports.engine.JRException: Error loading object from InputStream

    Can anybody help?

    Thanks a lot.

  3. shertage
    Wrote:
     

    Then, maybe the function name is the problem: in Microsoft Excel the names of functions depend on the language of the installed version of MS-Office. The TEIL name is available for the German language only. If the MSOffice isn't installed with the German as default language, the TEIL function is not recognized.

    Maybe you could try to use the equivalent MID() function, available for MSOffice with English as default language.

     

    The default language is German. Setting the TEIL function manually works. With JExcel API it works also.

    Using the MID() function raises an error with JExcel API and does nothing with JasperReports.

     

    Thank you, Gerhard

  4. shertage
    Wrote:
     


     

    JRXlsExporter exporter = new JRXlsExporter();

    exporter.setParameter(JRXlsExporterParameter.IS_DETECT_CELL_TYPE, Boolean.TRUE);

     

    Hope this helps,

    unfortunately not,

    I had already set this. Maybe it's better to work directly with JExcel API.

    Thank you.

  5. Hello,

    when exporting to Excel, I need to set a formula in some fields. This formula can dynamically change.
    Therefore I don't use XML, but build the report programmatically.
    So I set a textField like this:



    final JRDesignPropertyExpression propertyExpression = new JRDesignPropertyExpression();
    final JRDesignExpression expr = new JRDesignExpression();
    expr.setValueClass(java.lang.String.class);
    expr.setText("\"" + myExpression + "\"");
    propertyExpression.setName(JRAbstractExporter.PROPERTY_CELL_FORMULA);
    propertyExpression.setValueExpression(expr);

    final JRDesignTextField textField = new JRDesignTextField();
    textField.addPropertyExpression(propertyExpression);
    return textField;

    myExpression is a String variable in my own class and contains the desired excel formula, something like
    "teil(C2; 1; 3)". In the Eclipse debugger I can verify that the textField has a JRPropertiesMap
    with the entry "net.sf.jasperreports.export.xls.formula=teil(C2; 1; 3)" (Same problem with formula
    "TEIL(C2,1,3)" . And the textField is added
    to the detail band. But the cell in the generated Excel file is still empty.
    What is wrong here? Is there missing some step? Can you help?

    Thank you very much, Gerhard
     

  6. Hello,

     

    thanks for your reply. I changed to JRDesignPropertyExpression

    as you told me. I set my textField like this:

     

     

     

    final JRDesignPropertyExpression propertyExpression = new JRDesignPropertyExpression();

    final JRDesignExpression expr = new JRDesignExpression();

    expr.setValueClass(java.lang.String.class);

    expr.setText("\"" + myExpression + "\"");

    propertyExpression.setName(JRAbstractExporter.PROPERTY_CELL_FORMULA);

    propertyExpression.setValueExpression(expr);

     

    final JRDesignTextField textField = new JRDesignTextField();

    textField.addPropertyExpression(propertyExpression);

    return textField;

     

    myExpression is a variable in my own class and contains the desired excel formula, something like

    "teil(C2; 1; 3)". In the Eclipse debugger I can verify that the textField has a JRPropertiesMap

    with the entry "net.sf.jasperreports.export.xls.formula=teil(C2; 1; 3)". And the textField is added

    to the detail band. But the cell in the generated Excel file is still empty.

    What is wrong here? Is there missing some step? Can you help?

     

    Thank you very much, Gerhard

  7. Hi, all,

    I have a problem with dynamic excel formula. Because my reports are highly dynamically built, I don't
    use XML to design the report, but do it programmatically. For all columns with "normal" field values it's
    ok, but I'm running into problems with Excel formulas (which are also dynamical).

    I do the following: create a JRDesignTextField and add it to a detail band. To the textField I add a
    property expression like that:


    final JRPropertyExpression expression = new JRPropertyExpression() {

    @Override
    public void setName(String name) {
    // TODO
    }

    @Override
    public JRExpression getValueExpression() {
    final JRDesignExpression expr = new JRDesignExpression();
    expr.setValueClass(java.lang.String.class);
    expr.setText("\"![CDATA[" + someVariable + "]]\"");
    return expr;
    }

    @Override
    public String getName() {
    // TODO
    return JRAbstractExporter.PROPERTY_CELL_FORMULA;
    }
    };

    where someVariable contains "teil(C1; 1; 3)";

    This causes the following error:

    Expression ID not found for expression <<"![CDATA[teil(C1; 1; 3)]]">>.
    at net.sf.jasperreports.engine.base.JRBaseObjectFactory.getCollectedExpressionId(JRBaseObjectFactory.java:470)

    If I change the line expr.setText("\"![CDATA[" + someVariable + "]]\"");
    to
    expr.setText("![CDATA[" + someVariable + "]]");

    I get

    illegal start of expression
    value = (java.lang.String)(![CDATA["teil(C1; 1; 3)"]]); //$JR_EXPR_ID=12$

    Without the "CDATA" part I get the same errors when using "\"" or not.
    By debugging I found out, that some expressions are stored as a key in a Map and the value is an ID. But my JRPropertyExpression is not found in
    this map, which causes the "ID not found" error. Has anyone an idea how to solve this problem?

    I'm using JasperReports 3.6.0.

    Thank you very much, Gerhard
     

  8. Meanwhile I noticed that the code changings I made led to creating a temporary file in the folder "user.home"/tmp. But during the export process this file will never be attached again and doesn't change it's size.

    The export still runs into an OOME so I suspect that there is no effect from my changings. Or do I have to change

    some parameters or anything other?

    I'm running Jasper Reports 3.6.0 under Windows XP.

    Please help.

     

    Regards, Gerhard

     

  9. Hello,

    I read in the forum all about exporting large reports and with the help of FileVirtualizers I can
    now create large JasperPrint report representations. But I have to export to Excel and this
    fails with OutOfMemory.

    In the forum I read the following:

    "JExcelAPI has been made more memory-scalable in terms of writing Excel files.
     Starting from version 2.6.5 you can use useTemporaryFileDuringWrite.
    You probable need to subclass JExcelApiExporter in order to use this property."

    which was posted on 06/16/2008 16:12.

    I tried this, not with subclassing, but changing the code of "JExcelApiExporter"
    in the following way (changing openWorkbook):

     

     

     	final String pathname = System.getProperty("user.home") + "/tmp";
     	final File tempdir = new File(pathname);
     	WorkbookSettings ws = new WorkbookSettings();
     	ws.setTemporaryFileDuringWriteDirectory(tempdir);
     	ws.setUseTemporaryFileDuringWrite(true);
     	try {
     		workbook = Workbook.createWorkbook(os, ws);
     	} catch (IOException e) {
     		throw new JRException("Error generating XLS report : " + jasperPrint.getName(), e);
     	}
    
    
    
    But this did not help. Exporting still runs into OOME. Did I something wrong? Or is there
    another possible solution for the problem.
    
    Thanks for all answers.
    
    
     

  10. Hi, all,

    I have a problem with multiple JRDataSources.
    Two reports A and B work with their own Custom JRDatasource dsA and dsB. Both reports work fine standalone. But when I use the reports as subreports in a master report I try to set up the subreport connection type to
    "Use a datasource expression" and the expression itself to
    it.businesslogic.ireport.util.Misc.getJRDataSource( "dsA"), for subreport B
    it.businesslogic.ireport.util.Misc.getJRDataSource( "dsB"), respectively. When I try to preview I get the following error:

    Error filling print... Error evaluating expression :
          Source text : it.businesslogic.ireport.util.Misc.getJRDataSource("dsA")
    net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression :
          Source text : it.businesslogic.ireport.util.Misc.getJRDataSource("dsA")


    and so on.

    I found this solution in another thread of the forum titled "multiple datasource - problem".

    What is wrong? I use iReport 3.6.1.


    Thanks for any help, Gerhard
     

  11. Hi,

     

    I'd like to create a report with some subreports. The goal is to achieve an excel file with some sheets, each sheet

    should be filled by another subreport. But that's far away.

     

    I created two reports with a jdbc-connection. Both worked fine. In order to solve the problem described before I created

    another report and tried to add the two reports  as subreports to it. But always, when I try to add a subreport, the content

    of the datasources combobox changes to "Empty datasource" and therefore I get a report without any pages.

    I read in the forum that someone had a similar problem, but he didn't explain how he solved the problem.

    Can anybody help me?

    Thank you very much, Gerhard.

×
×
  • Create New...