This sample project demonstrates how to export reports to the necessary format from code. The sample represents an export to popular formats, if you need you can use any other exports in the same scenario. First, load the report you want to export, and render it with the WPF engine:
private void ButtonExport_Click(object sender, RoutedEventArgs e)
{
	var report = new StiReport();
	report.Load(@"Reports\TwoSimpleLists.mrt");
	report.Render();

...

Then, select the file format to which you want to export the report:
...

	var stream = new MemoryStream();
	
	switch (((Label)ComboBoxFormat.SelectedItem).Content)
	{
		case "PDF":
		report.ExportDocument(StiExportFormat.Pdf, stream);
		break;

		case "Word":
		report.ExportDocument(StiExportFormat.Word2007, stream);
		break;

		case "Excel":
		report.ExportDocument(StiExportFormat.Excel2007, stream);
		break;

		case "Text":
		report.ExportDocument(StiExportFormat.Text, stream);
		break;

		case "Image":
		report.ExportDocument(StiExportFormat.ImagePng, stream);
		break;
	}
	
	MessageBox.Show("The export action is complete.", "Export Report");
}

In the screenshot below you can see the result of the sample code:

Exporting a Report from Code

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.