cancel
Showing results for 
Search instead for 
Did you mean: 

Crystal Report and Swing application

Former Member
0 Kudos

We are evaluating crystal report and other reporting tools to use in our application.

The application is going to be developed in Java Swing. From this application, crystal report needs to be displayed. So, Is there possibility we can integrate crystal report with our application. The input data is going to be in XML and output should be in PDF.

We are expecting some thing like this.

Crystal report should provide Java APIs to integrate with our application. API should take XML as an Input data and crystal report template file(.rpt). It should return the output in pdf file.

If this is possible, can you tell me where I can get the sample codes?

Thanks,

Makesh

Accepted Solutions (1)

Accepted Solutions (1)

ted_ueda
Employee
Employee
0 Kudos

Have a look at our on-line docs, export tutorial [here|http://devlibrary.businessobjects.com/BusinessObjectsXIR2SP2/en/en/JRC_SDK/jrc_java_dg_doc/doc/jrcsdk_java_dg/Tutorials19.html#1586997].

Sincerely,

Ted Ueda

Former Member
0 Kudos

The information is useful. Thank you. But I don't find anything about passing XML data as input instead of JDBC data source.

Thanks,

Makesh

Edited by: Makesh on Sep 4, 2008 7:15 PM

ted_ueda
Employee
Employee
0 Kudos

Have you encountered designing Crystal Reports against XML data sources?

If so, which product version are you using?

Sincerely,

Ted Ueda

Former Member
0 Kudos

Yes, I can assign the XML data as input data source in Crystal Reports. I am expecting the same functionality supported by crystal reports APIs.

I am using the trial version of Crystal Reports 2008.

ted_ueda
Employee
Employee
0 Kudos

If you're using the Java Reporting Component, then:

1. There is currently no public report creation/modification API for that SDK.

2. The current Java Reporting Component (11.8) do not support Crystal Reports 2008.

Sincerely,

Ted Ueda

Former Member
0 Kudos

In other words, As of now, XML data can't be used as an Input source while programmatically exporting Crystal Reports.

Is that correct?

Makesh

ted_ueda
Employee
Employee
0 Kudos

You can:

1. Create a Crystal Report against XML data using the Designer. Then programmatically export that report.

2. Create a Crystal Report using the Desinger. Then programmatically "push" data into the report in XML format and export.

What you can't do currently with the JRC is create a report.

Sincerely,

Ted Ueda

Former Member
0 Kudos

Thank you for clarifying my doubts. I would be interested in case 2.

I want to do the exactly same thing.

First create a report using the designer. Then use the created report(.rpt file) and dynamic XML data to programmatically export the report in pdf format.

Where can I find the sample code for the above case? Most of the codes, I have come across, use only JDBC data source. I don't see any code using XML data source.

The only thing I am interested is how to pass("push") XML data programmatically. If I get any information regarding that, then I can develop my own program for the above case.

Thanks,

Makesh

ted_ueda
Employee
Employee
0 Kudos

Snippet for JRC XML "push":


ReportClientDocument rcd = new ReportClientDocument();
/*
 * Open and read CR Report and XML Data and Schema Files.  
 */
rcd.open("reports/test_xml.rpt", 0);
FileInputStream fin = new FileInputStream("reports/new_test_data.xsd");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] bytes = new byte[1024];
for(;;) {
	int count = fin.read(bytes);
	if(count < 0)
		break;
	baos.write(bytes, 0, count);
}
final byte[] xsdBytes = baos.toByteArray();
fin.close();

fin = new FileInputStream("reports/new_test_data.xml");
baos = new ByteArrayOutputStream();
bytes = new byte[1024];
for(;;) {
	int count = fin.read(bytes);
	if(count < 0)
		break;
	baos.write(bytes, 0, count);
}
final byte[] xmlBytes = baos.toByteArray();
fin.close();

/*
 * Inject XML data into CR Report using IXMLDataSet into
 * table "schema1/People".
 */
IXMLDataSet xml_ds = new IXMLDataSet() {
	private IByteArray xmlData = null;
	public void setXMLData(IByteArray xmlData) {
		this.xmlData = xmlData;
	}
	public IByteArray getXMLData() {
		return this.xmlData;
	}
	private IByteArray xmlSchema = null;
	public void setXMLSchema(IByteArray xmlSchema){
		this.xmlSchema = xmlSchema;
	}
	public IByteArray getXMLSchema() {
		return this.xmlSchema;
	}

};

xml_ds.setXMLData(new IByteArray() {
	public void fromString(String arrayValue){}
	public String toString() { return ""; }
	public byte[] getBytes() { return xmlBytes; }
});

xml_ds.setXMLSchema(new IByteArray() {
	public void fromString(String arrayValue){}
	public String toString() { return ""; }
	public byte[] getBytes() { return xsdBytes; }
});

rcd.getDatabaseController().setDataSource(xml_ds, "schema1/People", "schema1/People");

Sincerely,

Ted Ueda

Former Member
0 Kudos

Hi Ted

Can you please also share this Xml and Xsd file that you have used in the above example? It would be of great help. Or a zip of this working sample

Thanks

Prithumit

Answers (1)

Answers (1)

Former Member
0 Kudos

Thanks,

Makesh