水晶报表导出格式设定

首先新建一个枚举类型,将水晶报表的导出格式列出来。

/// <summary>
/// 可导出的文件格式.
/// </summary>
public enum AllowedExportFormat
{
    /// <summary>
    /// PDF.
    /// </summary>
    PDF = 1,
    /// <summary>
    /// Excel(97-2003)
    /// </summary>
    Excel2003 = 2,
    /// <summary>
    /// Word (97-2003)
    /// </summary>
    Word2003 = 4,
    /// <summary>
    /// RTF
    /// </summary>
    RTF = 8,
    /// <summary>
    /// Crystal Report
    /// </summary>
    CrystalReport = 16,
    /// <summary>
    /// Excel(97-2003) (仅限数据)
    /// </summary>
    Excel2003DataOnly = 32,
    /// <summary>
    /// Word (97-2003) - 可编辑
    /// </summary>
    Word2003EditAble = 64,
    /// <summary>
    /// XML
    /// </summary>
    XML = 128,
    /// <summary>
    /// Excel (仅限数据)
    /// </summary>
    ExcelDataOnly = 512,
    /// <summary>
    /// CSV
    /// </summary>
    CSV = 1024
}

新建类的静态方法,将可以选择的导出类型列出来。

    public static void ReportViewExport(CrystalReportViewer crv)
    {
        crv.AllowedExportFormats =
          (int)(AllowedExportFormat.CSV
          | AllowedExportFormat.Excel2003
          | AllowedExportFormat.Excel2003DataOnly
          | AllowedExportFormat.ExcelDataOnly
          | AllowedExportFormat.PDF
          | AllowedExportFormat.Word2003
          | AllowedExportFormat.Word2003EditAble
          | AllowedExportFormat.XML);
    }

页面进行调用

 protected void Page_Load(object sender, EventArgs e)
    {
        FN.ReportViewExport(ReportViewID);
        …
    }

效果图:

posted @ 2013-10-25 11:14  爱智旮旯  阅读(2331)  评论(1编辑  收藏  举报