This sample shows how to copy the same components StiPage, StiHeader and others between different reports. For example, let's use two reports OriginalReport and CustomReport.

First, you need to deserialize reports from files:
...

StiReport originalReport = StiSerializeManager.deserializeReport(
	StiResourceUtil.getStream("/com/stimulsoft/samples/OriginalReport.mrt"));
StiReport customerReport = StiSerializeManager.deserializeReport(
	StiResourceUtil.getStream("/com/stimulsoft/samples/CustomReport.mrt"));

...

Then you can copy the components. For this purpose, the serialization can be used:
...

StiHeaderBand originalHeader = (StiHeaderBand) originalReport.getComponents().get("HeaderBand1");
int originalIndex = originalHeader.getPage().getComponents().indexOf(originalHeader);
originalHeader.getPage().getComponents().remove(originalIndex);

StiHeaderBand customerHeader = (StiHeaderBand) customerReport.getComponents().get("HeaderBand1");
String originalHeaderStr = StiSerializerControler.serializedObjectAsString(customerHeader);
StiHeaderBand newCustomerHeader = new StiHeaderBand();
StiDeserializerControler.deserializeFromString(originalHeaderStr, newCustomerHeader);
newCustomerHeader.setPage(originalReport.getPages().get(0));
originalReport.getPages().get(0).getComponents().add(originalIndex, newCustomerHeader);
newCustomerHeader.setName(StiNameCreation.createName(originalReport, "HeaderBand"));
for (StiComponent component : newCustomerHeader.getComponents()) {
	component.setPage(originalReport.getPages().get(0));
	component.setParent(newCustomerHeader);
	component.setName(StiNameCreation.createName(originalReport, component.getName().replaceAll("\\d*", "")));
}

...

Auf dem Screenshot unten Sie können das Ergebnis des Beispiel-Codes ansehen:

Copying Components Between Reports

By using this website, you agree to the use of cookies for analytics and personalized content. Cookies store useful information on your computer to help us improve efficiency and usability. For more information, please read the privacy policy and cookie policy.