如何在没有服务器或 UI 的情况下从嵌入式报表定义生成 PDF? [英] How to generate a PDF from an embedded report definition without server or UI?

查看:30
本文介绍了如何在没有服务器或 UI 的情况下从嵌入式报表定义生成 PDF?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

独立的可执行文件是否可以在不显示 ReportViewer 控件的情况下生成报告并将其输出为 PDF(或报告查看器提供的其他导出选项之一)?

Is it possible for a stand alone executable to generate a report and output it as PDF (or one of the other export options available from the report viewer) without displaying the ReportViewer control?

报表定义应嵌入在可执行文件中,不应使用 Reporting Services Web 服务.

The report definition should be embedded in the executable and should not use the Reporting Services web service.

推荐答案

其实你根本不需要ReportViewer,直接实例化一个LocalReport就可以:

Actually you don't need a ReportViewer at all, you can directly instantiate and use a LocalReport:

LocalReport report = new LocalReport();
report.ReportPath = "templatepath";
// or use file from resource with report.ReportEmbeddedResource

// add parameters, datasource, etc.

Warning[] warnings;
string[] streamids;
string mimeType;
string encoding;
string filenameExtension;

byte[] bytes;
bytes =report.Render("PDF", null, out mimeType, out encoding, out filenameExtension, out streamids, out warnings);

// save byte[] to file with FileStream or something else

这篇关于如何在没有服务器或 UI 的情况下从嵌入式报表定义生成 PDF?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆