Jump to content
Changes to the Jaspersoft community edition download ×

Problemi con JRCSVDataSource


2005 IR Help

Recommended Posts

By: Gianni - gianni123

Problemi con JRCSVDataSource

2005-06-13 13:11

Salve. Ho il seguente problema con l'utilizzo di JRCSVDataSource.

 

Per disegnare un report ho configurato una sorgente dati ODBC in modo da poter utilizzare il wizard (la mia era solo una prova).

 

Poi ho compilato il report (creando un cm1221.jasper) ed ho creato un programma java per utilizzare il tutto senza ODBC (usando JRCSVDataSource).

 

Mi esce però©¬ seguente errore:

 

 

java.lang.StringIndexOutOfBoundsException: String index out of range: -2

at java.lang.String.substring(String.java:1444)

at java.lang.String.substring(String.java:1411)

at it.businesslogic.ireport.connection.JRCSVDataSource.getFieldValue(JRCSVDataSource.java:29)

at net.sf.jasperreports.engine.fill.JRBaseFiller.next(JRBaseFiller.java:872)

at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:116)

at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:622)

at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:116)

at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:428)

at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:344)

at rtsReport.PrintReport.main(PrintReport.java:34)

 

 

=========================================

 

Questi sono i dati presenti nel file csv (sia con i ; alla fine che senza non funziona ugualmente)

 

 

========================================

 

N_doc;Data_doc;Centro;Desc_centro;Tipo_oper;Desc_oper;N_riga;Turno;Macc;Commessa;Bolla;Linea;Cambi;N_scheda;Inizio;Fine;Composizione;

 

L01280;22/03/2005;41;CASEMAKER1 ------------------> ; A;AVVIAMENTO ;1;1;666;180301;1;55;1; ;14.20;15.00;KFK/242/B ;

 

L01280;22/03/2005;41;CASEMAKER1 ------------------> ; P;PRODUZIONE ;2;1;666;180301;1;55;0; 12BIS ;15.00;16.00;KFK/242/B ;

 

L01280;22/03/2005;41;CASEMAKER1 ------------------> ; S;S ;3;1;666;180301;1;55;0; ;14.20;14.20;KFK/242/B ;

 

L01281;22/03/2005;41;CASEMAKER1 ------------------> ; A;AVVIAMENTO ;1;2;666;155001;1;55;1; ;16.00;16.30;KFK/242/B ;

 

L01281;22/03/2005;41;CASEMAKER1 ------------------> ; P;PRODUZIONE ;2;2;666;155001;1;55;0;112;16.30;17.30;KFK/242/B ;

 

L01281;22/03/2005;41;CASEMAKER1 ------------------> ; S;S ;3;2;666;155001;1;55;0; ;16.00;16.00;KFK/242/B ;

 

==================================

 

E questa e' la mia classe java:

 

==================================

 

public class PrintReport {

 

public static void main(String[] args) {

if (! (args.length == 3))

{

System.out.println("Parametri da usare:");

System.out.println("1 -> File csv (sorgente dati)");

System.out.println("2 -> File jasper (report di stampa)");

System.out.println("3 -> Nome del pdf di output");

System.exit(1);

}

try

{

String reportFileName = args[1];

HashMap hm = new HashMap();

String csvFileName = args[0];

String outFileName = args[2];

JRCSVDataSource jrcsvds = new JRCSVDataSource(csvFileName);

JasperPrint print = JasperFillManager.fillReport(reportFileName, hm, jrcsvds);

JRExporter exporter = new JRPdfExporter();

exporter.setParameter( JRExporterParameter.OUTPUT_FILE_NAME, outFileName);

exporter.setParameter( JRExporterParameter.JASPER_PRINT, print);

exporter.exportReport();

System.out.println("Creato il file:" + outFileName);

}

catch (Exception e)

{

e.printStackTrace();

System.exit(1);

}

}

}

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Popular Days

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...