This sample project demonstrates how to export reports to the necessary format from code and save the result. The sample represents an export to popular formats, if you need you can use any other exports in the same scenario. First, specify the path to the reports you want to export:
private void button1_Click(object sender, System.EventArgs e)
{
	StiReport report = new StiReport();

	report.Load("..\\..\\Reports\\" + (string)lbReports.SelectedItem + ".mrt");
	report.Render(false);
	
...

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

	string file = (string)lbReports.SelectedItem + ".";
	
	if (rbPdf.Checked)
	{
		file += "pdf";
		report.ExportDocument(StiExportFormat.Pdf, file);
		System.Diagnostics.Process.Start(file);
	}
	else if (rbHtml.Checked)
	{
		file += "html";
		report.ExportDocument(StiExportFormat.HtmlTable, file);
		System.Diagnostics.Process.Start(file);
	}
	else if (rbXls.Checked)
	{
		file += "xls";
		report.ExportDocument(StiExportFormat.Excel, file);
		System.Diagnostics.Process.Start(file);
	}
	else if (rbTxt.Checked)
	{
		file += "txt";
		report.ExportDocument(StiExportFormat.Text, file);
		System.Diagnostics.Process.Start(file);
	}
	else if (rbRtf.Checked)
	{
		file += "rtf";
		report.ExportDocument(StiExportFormat.RtfTable, file);
		System.Diagnostics.Process.Start(file);
	}
}

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

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.