翻譯|使用教程|編輯:王香|2018-09-20 09:39:23.000|閱讀 482 次
概述:本文主要介紹Stimulsoft報表中從代碼導出報表。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
【下載Stimulsoft Reports.WPF最新版本】
此示例項目演示了如何從代碼中將報表導出為必要的格式。該示例表示導出為常用格式,如果需要,可以在同一場景中使用任何其他導出。首先,加載要導出的報表,然后使用WPF引擎進行渲染:
private void buttonExport_Click(object sender, RoutedEventArgs e) { StiReport report = new StiReport(); report.RegData(dataSet1); report.Load("..\\" + ((ListBoxItem)lbReports.SelectedItem).Content as string + ".mrt"); report.RenderWithWpf(false); ...
然后,選擇要將報表導出到的文件格式:
... string file = ((ListBoxItem)lbReports.SelectedItem).Content as string + "."; if (rbPdf.IsChecked.GetValueOrDefault()) { file += "pdf"; report.ExportDocument(StiExportFormat.Pdf, file); System.Diagnostics.Process.Start(file); } else if (rbHtml.IsChecked.GetValueOrDefault()) { file += "html"; report.ExportDocument(StiExportFormat.HtmlTable, file); System.Diagnostics.Process.Start(file); } else if (rbXls.IsChecked.GetValueOrDefault()) { file += "xls"; report.ExportDocument(StiExportFormat.Excel, file); System.Diagnostics.Process.Start(file); } else if (rbTxt.IsChecked.GetValueOrDefault()) { file += "txt"; report.ExportDocument(StiExportFormat.Text, file); System.Diagnostics.Process.Start(file); } else if (rbRtf.IsChecked.GetValueOrDefault()) { file += "rtf"; report.ExportDocument(StiExportFormat.RtfTable, file); System.Diagnostics.Process.Start(file); } }
示例代碼的結果如下圖所示:
購買Stimulsoft正版授權,請點擊“”喲!
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn