-
July 26th, 2010, 12:38 AM
#1
Refreshing crystal report using java
I have a crystal report which is getting displayed in PDF format using java.The Crystal report is using CSV file as the datasource.
Now the issue is if the CSV file is getting updated the Crysta report is not getting refreshed thorugh java coding and is always showing the initial data not the updated data.
I am using JRC and ReportClientDocument object for opening the crysatl report from java.
-
July 26th, 2010, 02:09 PM
#2
Re: Refreshing crystal report using java
OK, I don't have a Crystal Ball to look at your Crystal Reports code , so any answer would be a guess.
I would think though that this might be a problem for a Crystal Reports forum. If you disagree, you need to post your code (or a reduced example of what isn't working) in code tags. Please also provide any error messages or exceptions (full stack trace in code tags) you are receiving.
Remember, the better your question is and the less guessing we have to do, the better our answer will be.
-
July 27th, 2010, 03:03 AM
#3
Re: Refreshing crystal report using java
Hi,
Please find my code snippet below.I have the csv file in the same location as the report file.
Also in the report I have selected the CSV file as the datasource.
ReportClientDocument reportClientDoc = new ReportClientDocument();
if(reportClientDoc != null)
{
try {
reportClientDoc.open("C://Documents and Settings//Riguser//Desktop//directionalDepthSurvey.rpt",0);
System.out.println("report opened");
ParameterFieldController paramFieldController = reportClientDoc.getDataDefController().getParameterFieldController();
int size = reportClientDoc.getDataDefController().getDataDefinition().getParameterFields().size();
Fields reportFields = reportClientDoc.getDataDefController().getDataDefinition().getParameterFields();
for(int i = 0; i < size; i++){
if(reportFields.getField(i).getName().equalsIgnoreCase("WellID")){
paramFieldController.setCurrentValue("", "WellID", wellId);
}
if(reportFields.getField(i).getName().equalsIgnoreCase("RigNum")){
paramFieldController.setCurrentValue("", "RigNum", rigNbr);
}
}
System.out.println("parameter sets");
try{
File staticReport = new File("C://Documents and Settings//Riguser//Desktop//dirctionalDepthSurvey.pdf");
if(staticReport.exists())
{
staticReport.delete();
}
else
{
staticReport.createNewFile();
}
System.out.println(staticReport);
FileOutputStream fos = new FileOutputStream(staticReport);
is = reportClientDoc.getPrintOutputController().export(ReportExportFormat.PDF);
BufferedInputStream bis = new BufferedInputStream(is);
// Copy output to input stream
byte[] buffer = new byte[1024];
while(bis.read(buffer) > 0){
fos.write(buffer);
}
bis.close();
fos.close();
is.close();
}
catch(Exception e){
e.printStackTrace();
}
finally{
// this block was added by Anil to fix the memory leak issue
// with reportviewer bean
if(reportClientDoc != null){
reportClientDoc.getReportSource();//.dispose();
reportClientDoc.close();
reportClientDoc = null;
}
}
} catch (ReportSDKException ex) {
}
Please help !
Thanks
SANJUJOB
-
July 27th, 2010, 08:36 AM
#4
Re: Refreshing crystal report using java
Code tags [ code] [ \code] will preserve your formatting and make the code easier for us to read.
Any errors? Any exceptions thrown? How does this code get executed? Again, I don't know if anyone here is familiar with Crystal Reports, so any details you can provide will be helpful. If you posted this on a CR forum, you might get an immediate answer.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|