发布时间 : 2015-12-15 10:23:03.000|阅读 1921 次
概述:本片文章主要介绍Stimulsoft Reports.Net开发者在输出报表时遇到的常见问题及解决方案。
相关链接:
< Stimulsoft Reports.Net v2015.3最新版本下载>
举个例子,将报表输出为PDF:
C#
StiReport report = new StiReport(); report.Load("report.mrt"); report.Render(); report.ExportDocument(StiExportFormat.Pdf, "document.pdf");
VB
Dim Report As StiReport = New StiReport() Report.Load("report.mrt") Report.Render() Report.ExportDocument(StiPdfExportFormat.Pdf, "document.pdf")
按照下面的方法在不使用对话框的情况下就可以输出报表:
C#
StiReport report = new StiReport(); report.Load("report.mrt"); report.Render(); //Variant 1 StiPdfExportService pdfExport = new StiPdfExportService(); pdfExport.ExportPdf(report, "document.pdf"); //Variant 2 report.ExportDocument(StiExportFormat.Pdf, "document.pdf");
VB
Dim Report As StiReport = New StiReport() Report.Load("report.mrt") Report.Render() 'Variant 1 Dim PdfExport As StiPdfExportService = New StiPdfExportService() PdfExport.ExportPdf(Report, "document.pdf") 'Variant 2 report.ExportDocument(StiExportFormat.Pdf, "document.pdf")
在这个例子中,报表被输出为PDF格式。你也可以使用下面的类将报表输出为其它可用的格式:
你需要禁用所有不需要的报表输出组件,同样你也得使用Configurator.exe应用程序禁用服务。
StiConfig.Load(); StiServiceContainer services = StiConfig.Services.GetServices(typeof(StiExportService)); foreach (StiService service in services) { if (service is StiBmpExportService)service.ServiceEnabled = false; if (service is StiCsvExportService)service.ServiceEnabled = false; if (service is StiEmfExportService)service.ServiceEnabled = false; if (service is StiGifExportService)service.ServiceEnabled = false; if (service is StiHtmlExportService)service.ServiceEnabled = false; if (service is StiJpegExportService)service.ServiceEnabled = false; if (service is StiPdfExportService)service.ServiceEnabled = false; if (service is StiRtfExportService)service.ServiceEnabled = false; if (service is StiTiffExportService)service.ServiceEnabled = false; if (service is StiTxtExportService)service.ServiceEnabled = false; if (service is StiXmlExportService)service.ServiceEnabled = false; } StiConfig.Save();
使用StiPage的GetThumbnail方法:
C#
Bitmap bmp = page.GetThumbnail(200, 300);
VB
Dim Bmp As Bitmap = Page.GetThumbnail(200, 300)
导出为HTML可以在两种模式下工作:Table和Span。在Table模式中Stimulsoft Reports.Net生成一张大表,并将组件从页面写入到表行中。但在这种模式下页面上的组件将不被交叉。在Span模式中报表引擎为每个组件生成横跨对象。在这种情况下组件就会在页面上交叉。
ExcelValue属性是用于将数值输出为Excel。默认情况下StiText组件被输出为Excel的文本格式。
StiText组件的ExcelValue属性的表达式将被输出到Excel单元格,并且格式为数字。
购买最新正版授权!"咨询在线客服"
慧都年终盛典火爆开启,一年仅一次的最强促销,破冰钜惠不容错过!!优惠详情点击查看>>