Crystal报告下一页自动化

Crystal报告下一页自动化

本文介绍了ASPX Crystal报告下一页自动化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

大家好,



首先让我说我知道网上可能有数百个帖子提到asp和CR。我找了大约一个星期试图无济于事。如果你有一个你认为会有帮助的网页,我会很高兴看到它,但我一遍又一遍地谷歌这个主题。



我正在开发一个asp / C#项目,它将获取任何水晶报告并将其显示在网页上,该部分非常简单。在这个项目中,我正在寻找简单的东西,可以在任何类型的浏览器或操作系统上连续几天/几周运行。我正在使用CR XIR2,asp.net 4.0和VS2010。我的项目将显示报告并刷新数据并报告设定的时间段。我的项目中没有数据集。该报告直接连接到SQL服务器并提取数据。我已经在asp页面上使用一些javascript进行了自动页面刷新,但是我无法自动化下一页显示。我希望每两分钟左右轮换一次页面,每10分钟左右刷新整个报告。这是我的asp页面:



Hello all,

First let me say I know that there are probably hundreds of postings on the net that refer to asp and CR. I have looked for about a week trying things to no avail. If you have a web page that you think will help I would be very happy to check it out, but I have google''d this subject over and over again.

I am working on a asp/C# project that will take any crystal report and display it on a web page, that part is simple enough. In this project I am looking for simplicity, something that will run possible for days/weeks on end on any type of browser or OS. I am using CR XIR2, asp.net 4.0 and VS2010. My project will display a report and refresh the data and report on a set time period. I do not have a dataset in my project. The report connects directly to the SQL server and pulls the data. I have gotten the automated page refresh working with some javascript on the asp page, but I am having trouble automating the next page display. I am looking to rotate through the pages every two minutes or so and refresh the entire report every 10 mins or so. Here is my asp page:

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register TagPrefix="CR" Namespace="CrystalDecisions.Web" Assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" %>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
    <script type="text/javascript">
        function timeClick() {
            var t = setTimeout("clickButton()", 180000);
        }

        function clickButton() {
            var button = document.getElementById('RefreshButton');
            button.click();
            timeClick();
        }
</script>
<script type="text/C#"  runat="server">
    public void CommandBtn_Click(object sender, CommandEventArgs e)
    {
        CrystalReportViewer1.RefreshReport();
    }
</script>
</head>
<body>
<script type="text/javascript">
    window.onload = timeClick;
</script>
    <form id="form1" runat="server">
    <div style="display: none;">
        <asp:Button ID="RefreshButton" runat="server" onCommand="CommandBtn_Click" />
    </div>
    <div>
        <CR:CrystalReportViewer ID="CrystalReportViewer1"  runat="server" AutoDataBind="True"
            Height="1039px" ReportSourceID="CrystalReportSource1" Width="901px" DisplayStatusbar="False"
            HasDrilldownTabs="False" HasToggleGroupTreeButton="False"
            HasToggleParameterPanelButton="False" ToolPanelView="None" />
        <CR:CrystalReportSource ID="CrystalReportSource1"  runat="server">
            <Report FileName="CrystalReport1.rpt">
            </Report>
        </CR:CrystalReportSource>

    </div>
    </form>
</body>
</html>















这里是我的C#代码:










And here is my C# code behind:

using System;
using System.Data;
using System.Configuration;

using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using CrystalDecisions.Shared;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Web;

public partial class _Default : System.Web.UI.Page
{
    private ReportDocument rpt;

    private void Page_Init(object sender, EventArgs e)
    {
        ConfigureCrystalReports();
    }
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    private void ConfigureCrystalReports()
    {
        rpt = new ReportDocument();
        string reportPath = Server.MapPath("CrystalReport1.rpt");
        rpt.Load(reportPath);
        ConnectionInfo connectionInfo = new ConnectionInfo();
        connectionInfo.DatabaseName = "******";
        connectionInfo.UserID = "*****";
        connectionInfo.Password = "*****";
        SetDBLogonForReport(connectionInfo, rpt);
        CrystalReportViewer1.ReportSource = rpt;
    }
    private void SetDBLogonForReport(ConnectionInfo connectionInfo, ReportDocument reportDocument)
    {
        Tables tables = reportDocument.Database.Tables;
        foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)
        {
            TableLogOnInfo tableLogonInfo = table.LogOnInfo;
            tableLogonInfo.ConnectionInfo = connectionInfo;
            table.ApplyLogOnInfo(tableLogonInfo);
        }
    }
}







我遗漏了我尝试过的许多不同的方法。我希望有人可以提供帮助......先谢谢。




I have left out the many different approaches I have attempted. I hope someone can help.... Thanks in advance.

推荐答案

<script type="text/javascript">
function nextPg_timeClick() {
            var i = setTimeout("nextPg_Click()", 1800);
        }
        function nextPg_Click() {
            var button1 = document.getElementById('nextPg');
            button1.click();
            nextPg_timeClick();
        }
</script>
<script type="text/C#"  runat="server">
    public void Commandnav_Click(object sender, CommandEventArgs e)
    {
        CrystalReportViewer1.ShowNextPage();
    }
</script>


<asp:button id="nextPg" runat="server" oncommand="Commandnav_Click" 


这篇关于ASPX Crystal报告下一页自动化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 20:19