水晶レポートはExcel、Image、PDF---LocalReportにエクスポートされます.Render


LocalReport.Renderメソッド(String,String,String,String,String,String,String[],Warning[])
レポートを処理し、指定したフォーマットでレポートを表示します.
名前空間:Microsoft.Reporting.WinFormsプログラムセット:Microsoft.ReportViewer.WinForms(Microsoft.reportviewer.winforms.dll)
public override byte[] Render (
    string format,
    string deviceInfo,
    [OutAttribute] ref string mimeType,
    [OutAttribute] ref string encoding,
    [OutAttribute] ref string fileNameExtension,
    [OutAttribute] ref string[] streams,
    [OutAttribute] ref Warning[] warnings
)

パラメータ
format
レポートのフォーマットを表示します.このパラメータは、レンダリング拡張プラグインにマッピングされます.サポートされるフォーマットには、Excel、PDF、Imageが含まれます.
deviceInfo
フォーマットパラメータで指定した拡張プラグインのレンダリングに必要なデバイス固有のコンテンツを含むXML文字列.特定の出力フォーマットのデバイス情報設定の詳細については、SQL Server 2005 Reporting Servicesドキュメントのデバイス情報設定を参照してください.
mimeType
[out]表示されるレポートのMIMEタイプ.
encoding
[out]レポートの内容を表示する際に使用する符号化.
fileNameExtension
[out]ファイルを出力するためのファイル拡張子.
streams
[out]ストリーム識別子.レポートに関連付けられた外部リソース(画像など)を表示するには、これらを使用します.
warnings
[out]レポート処理中に発生した警告を記述するWarningオブジェクトのセット.
戻り値指定されたフォーマットのレポートの
Byte配列.

次のコード例では、ReportViewerコントロールとボタンを含むWindowsフォームアプリケーションを想定します.このコードには、コントロールにロードされて表示されるローカル・レポートと、レポートをMicrosoft Excel形式にエクスポートするためのRenderメソッドが表示されます.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.Reporting.WinForms;
using System.IO;

namespace SampleCode
{
    public partial class Form1 : Form
    {
        private DataTable LoadSalesData()
        {
            // Load data from XML file.
            DataSet dataSet = new DataSet();
            dataSet.ReadXml(@"c:\Reports\data.xml");
            return dataSet.Tables[0];
        }
        
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            this.reportViewer1.ProcessingMode = ProcessingMode.Local;
            this.reportViewer1.LocalReport.ReportPath = @"c:\Reports\Report1.rdl";
            reportViewer1.LocalReport.DataSources.Add(
            new ReportDataSource("Sales", LoadSalesData()));
            this.reportViewer1.RefreshReport();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Warning[] warnings;
            string[] streamids;
            string mimeType;
            string encoding;
            string extension;

            byte[] bytes = reportViewer1.LocalReport.Render(
               "Excel", null, out mimeType, out encoding, out extension, 
               out streamids, out warnings);

            FileStream fs = new FileStream(@"c:\output.xls", FileMode.Create);
            fs.Write(bytes, 0, bytes.Length);
            fs.Close();

            MessageBox.Show("Report exported to output.xls", "Info");

        }
    }
}
    :http://msdn.microsoft.com/zh-cn/library/ms252207(VS.80).aspx