翻譯|使用教程|編輯:王香|2018-09-20 09:39:23.000|閱讀 482 次
概述:本文主要介紹Stimulsoft報(bào)表中從代碼導(dǎo)出報(bào)表。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
【下載Stimulsoft Reports.WPF最新版本】
此示例項(xiàng)目演示了如何從代碼中將報(bào)表導(dǎo)出為必要的格式。該示例表示導(dǎo)出為常用格式,如果需要,可以在同一場(chǎng)景中使用任何其他導(dǎo)出。首先,加載要導(dǎo)出的報(bào)表,然后使用WPF引擎進(jìn)行渲染:
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); ...
然后,選擇要將報(bào)表導(dǎo)出到的文件格式:
... 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); } }
示例代碼的結(jié)果如下圖所示:
購(gòu)買Stimulsoft正版授權(quán),請(qǐng)點(diǎn)擊“”喲!
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn