Skip to Content
author's profile photo Former Member
Former Member

Help needed in reading data from a Crystal Report

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

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Jun 05, 2014 at 05:14 PM

    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.


    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.