Exporting a Report from Code
Unsere Beispiele der Projekte und Berichtsvorlagen helfen Ihnen, die Grundlagen der Arbeit mit unserer Software zu erlernen.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:
Then, select the file format to which you want to export the report:
Auf dem Screenshot unten Sie können das Ergebnis des Beispiel-Codes ansehen:

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:
