4,819
社区成员




using System.Windows.Forms;
using Microsoft.Reporting.WinForms;
using System.IO;
private void pdfExport()
{
//回写测试,如果可以回写到数据集中,然后更新RDLC,并输出,那么就用这种模式
//refresh report viewer
Warning[] warnings;
string[] streamids;
string mimeType;
string encoding;
string extension;
byte[] bytes = this.reportViewer1.LocalReport.Render(
"pdf", null, out mimeType, out encoding, out extension,
out streamids, out warnings);
FileStream fs = new FileStream(@"d:/output.pdf", FileMode.Create);
fs.Write(bytes, 0, bytes.Length);
fs.Close();
MessageBox.Show("报表已经成功导出到桌面!", "Info");
//ExportRpt(0);
}
Microsot.Reporting.WinForms.Warning[] Warnings;
string[] strStreamIds;
string strMimeType;
string strEncoding;
string strFileNameExtension;
byte[] bytes = this.rptViewer.LocalReport.Render("Excel", null, out strMimeType, out strEncoding, out strFileNameExtension, out strStreamIds, out Warnings);
string strFilePath = @"D:\report.xls";
using (System.IO.FileStream fs = new FileStream(strFilePath, FileMode.Create))
{
fs.Write(bytes, 0, bytes.Length);
}