如何将多个 Crystal Report 放入一个 Crystal Report 查看器中?

发布于 2024-10-09 08:58:51 字数 208 浏览 6 评论 0原文

所以事情是这样的..

我编写了 ac# 应用程序,为每个员工生成每月的出勤报告,并附有他自己的详细信息 我希望能够为所有员工执行一次此操作并查看按姓名分组的报告 因此,当我从水晶报表子树中选择客户名称时,我会得到他的每月出勤报告,

我真的不知道如何在水晶报表中使用子树......是否有可能这样做?


所有这一切的目标是能够一键打印所有报告

So here is the thing ..

I wrote a c# application to generate monthly Attendance Reports for each employee with his own details
I want to be able to do this once for all employees and view the report grouped by name
so when I select the customer name from the crystal report sub tree I get his monthly Attendance Report

I don't really know how to use the sub tree in crystal report ... is it possible to something like that ?


the goal from all this is to be able to print all reports at once in one click

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

萌能量女王 2024-10-16 08:58:51

这并不完全是您所要求的,但我将发布它,因为它可能对您有用。我在类似的情况下为我做了。另外对 VB 语法表示抱歉。

这将允许您使用 Crystal Reports 引擎将报告创建为 PDF。基本上,它允许您使用循环创建多个 PDF,然后可以自动打印。Export PDF Sub 会将文件写入磁盘,然后使用默认的 pdf 阅读器打开它。打印 PDF 功能将自动打印保存到磁盘的 PDF 文件。这不是一个完美的解决方案,但我希望它至少能让您更接近您想要实现的目标。

公共类 PDFCR

Private Const SW_SHOWNORMAL As Integer = 2
<DllImport("shell32")> _
Public Shared Function ShellExecute(ByVal hWnd As IntPtr, _
                                    ByVal lpOperation As String, _
                                    ByVal lpFile As String, _
                                    ByVal lpParameters As String, _
                                    ByVal lpDirectory As String, _
                                    ByVal nShowCmd As Integer) As IntPtr
End Function

Public Shared Sub ExportPDF(ByVal crDOC As ReportDocument, ByVal FilePath As String)
    Dim CrExportOptions As ExportOptions
    Dim CrDiskFileDestinationOptions As New DiskFileDestinationOptions()
    Dim CrFormatTypeOptions As New PdfRtfWordFormatOptions()
    CrDiskFileDestinationOptions.DiskFileName = FilePath
    CrExportOptions = crDOC.ExportOptions
    CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile
    CrExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat
    CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions
    CrExportOptions.FormatOptions = CrFormatTypeOptions
    crDOC.Export()
    Process.Start(FilePath)
End Sub

Public Shared Function PrintPDF(ByVal FilePath As String) As Boolean
    If IO.File.Exists(FilePath) Then
        If ShellExecute(CType(1, IntPtr), "Print", FilePath, "", _
        Directory.GetDirectoryRoot(FilePath), SW_SHOWNORMAL).ToInt32 <= 32 Then
            Return False
        Else
            Return True
        End If
    Else
        Return False
    End If
End Function

结束类

我无法让导入在此代码块中显示,因此这里它们以纯文本形式显示。

导入 System.IO

导入 System.Management

导入 CrystalDecisions.Shared

导入 System.Runtime.InteropServices

导入 CrystalDecisions.CrystalReports.Engine

This is not exactly what you asked for but I am going to post it because it may work for you. I did for me in a similar situation. Also sorry about the VB syntax

This will allow you to create your reports as PDFs using the Crystal Reports engine. Basically it will allow you to create multiple PDF using a loop, which can then be printed automatically.The Export PDF Sub will write the file to disk and then open it with the default pdf reader. The print PDF function will automaticaly print the PDF files that were saved to disk. This is not a perfect solution but I hope that it at least gets you closer to what you are trying to accomplish.

Public Class PDFCR

Private Const SW_SHOWNORMAL As Integer = 2
<DllImport("shell32")> _
Public Shared Function ShellExecute(ByVal hWnd As IntPtr, _
                                    ByVal lpOperation As String, _
                                    ByVal lpFile As String, _
                                    ByVal lpParameters As String, _
                                    ByVal lpDirectory As String, _
                                    ByVal nShowCmd As Integer) As IntPtr
End Function

Public Shared Sub ExportPDF(ByVal crDOC As ReportDocument, ByVal FilePath As String)
    Dim CrExportOptions As ExportOptions
    Dim CrDiskFileDestinationOptions As New DiskFileDestinationOptions()
    Dim CrFormatTypeOptions As New PdfRtfWordFormatOptions()
    CrDiskFileDestinationOptions.DiskFileName = FilePath
    CrExportOptions = crDOC.ExportOptions
    CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile
    CrExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat
    CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions
    CrExportOptions.FormatOptions = CrFormatTypeOptions
    crDOC.Export()
    Process.Start(FilePath)
End Sub

Public Shared Function PrintPDF(ByVal FilePath As String) As Boolean
    If IO.File.Exists(FilePath) Then
        If ShellExecute(CType(1, IntPtr), "Print", FilePath, "", _
        Directory.GetDirectoryRoot(FilePath), SW_SHOWNORMAL).ToInt32 <= 32 Then
            Return False
        Else
            Return True
        End If
    Else
        Return False
    End If
End Function

End Class

I was having trouble getting the Imports to show in this code block so here they are in plain text.

Imports System.IO

Imports System.Management

Imports CrystalDecisions.Shared

Imports System.Runtime.InteropServices

Imports CrystalDecisions.CrystalReports.Engine

离旧人 2024-10-16 08:58:51

如果您在报告中的“员工姓名”字段中添加“组”,这将(默认情况下)创建您正在查找的组树。

从那里,从代码角度来说,它可以被关闭,但如果您的报表中有任何组,您应该默认看到组树。

问题似乎是报告没有按员工姓名分组。

If you add a GROUP to your report on your Employee Name field, this will (by default) create the group tree you are looking for.

From there, code-wise, it can be turned off, but you should see the group tree by default if your report has any groups in it.

The problem seems to be with the report not being grouped on Employee Name.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文