cancel
Showing results for 
Search instead for 
Did you mean: 

Help needed in reading data from a Crystal Report

Former Member
0 Kudos

I am trying to read data values from a saved crystal report. (groovy code snippet below)

I open a new ReportClientDocument and set the RAS using the inprocConnectionString property.

Then I get the rowsetController and set defaultNumOfBrowsingRecords, rowsetBatchSize and maxNumOfRecords all to 1000000

Using the browseFieldValues method after that returns only 100 records. I want to get all.

  
    	  ReportClientDocument clientDocSaved;
		   
	  def pathout=rc.pathToSavedReports+rr.path;
	       
	//****** BEGIN OPEN SAVED SNAPSHOT ************

	clientDocSaved = new ReportClientDocument();
	clientDocSaved.setReportAppServer(ReportClientDocument.inprocConnectionString); 	  
	
        // Open report
	println("Reading file in.")
	clientDocSaved.open(pathout, OpenReportOptions._openAsReadOnly);
        
       def rowsetController = clientDocSaved.getRowsetController()
	rowsetController.setDefaultNumOfBrowsingRecords(1000000)
	rowsetController.setRowsetBatchSize(1000000)
	rowsetController.setMaxNumOfRecords(1000000)
		  
		  
	//setup metadata
	IRowsetMetaData rowsetMetaData = new RowsetMetaData()
	Fields fields =  clientDocSaved.getDataDefController().getDataDefinition().getResultFields()
	rowsetMetaData.setDataFields(fields)
		  
	def values = rowsetController.browseFieldValues(fields.get(0), 1000000)
	 
	values.each{value->
	   println(value.displayText(new Locale("ENGLISH")))
	}

Before using the browseFieldValues method I was trying to use a rowsetCursor


		  //get the rowset cursor to navigate through the results
		  RowsetCursor rowsetCursor = clientDoc.getRowsetController().createCursor(null, rowsetMetaData)
		  
		  //navigate through the rowset and log the name and value
		  rowsetCursor.moveTo(0)
		  while(!rowsetCursor.isEOF()){
			  Record currentRecord = rowsetCursor.getCurrentRecord()
			  //println("current record number: " + rowsetCursor.getCurrentRecordNumber())
			  for(int i=0;i<fields.size();i++){
				  //println("Column - "+fields.get(i).getName())
				  if (currentRecord.size()>0){
					 println(currentRecord.getValue(i))
				  }
		
			  }
			  rowsetCursor.moveNext()
		  }

the currentRecord was always an empty list and I did not get any data values at all.

Am I missing something in using these approaches?

I'm fairly new to using the Java SDK for CR. Any help will be greatly appreciated.

Thanks

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

hi, I am trying this second method to read the values from report. but all the records comming as null. Kindly help me to resolve this issue.