簡體   English   中英

報告查看器控件將內容導出為pdf

[英]report viewer control exporting content to pdf

我正在為客戶創建asp.net網絡應用程序,他喜歡在他的頁面上有報告,所以我在頁面rdlc文件上,我使用默認的asp.net報表查看器控件在頁面上顯示此文件...一切都是好的,除非客戶端想要將文件保存為pdf時頁面的結構發生變化並且看起來不一樣我也注意到字段中的某些值為空但它們出現在頁面上並且當我保存相同的報告時在Word(*。doc)格式中,單詞文件也應該是......問題僅在於pdf。 歡迎任何建議

問題是由於報告屬性中的邊距設置,如果您遇到相同的問題,請將邊距設置(左,右,上,下)設置為0in。 而你的問題就解決了。

試試這個代碼....它將有助於以pdf格式顯示你的數據

    protected void submit_Click(object sender, EventArgs e)
    {
        bindReportData();  
        try
        {
            // Export the Report to Response stream in PDF format and file name Customers

            abc_reportDocument.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, true, "ABC");
            // There are other format options available such as Word, Excel, CVS, and HTML in the ExportFormatType Enum given by crystal reports
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
            ex = null;
        }
    }



    private void bindReportData()
    {
        abc_reportDocument = new ReportDocument();
        dsReport = new DataSet();
        dsReport = getAccumulationData();
        if (dsReport.Tables[0].Rows.Count > 0)
        {
            abc_reportDocument.Load(this.MapPath("report1.rpt"));
            abc_reportDocument.Database.Tables[0].SetDataSource(dsReport.Tables[0]);
            rptviewerAccumulation.ReportSource = abc_reportDocument;
            rptviewerAccumulation.DataBind();


        }

}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM