【问题标题】:Exporting pdf file using Crystal report (Allow user to choose file path)?使用 Crystal 报表导出 pdf 文件(允许用户选择文件路径)?
【发布时间】:2014-12-11 06:52:34
【问题描述】:

我知道如何使用 Crystal Report 导出为 pdf,但我不想预设文件路径,我希望用户在单击导出按钮时可以选择文件路径(和文件名)。

你知道怎么做吗?

非常感谢,

【问题讨论】:

  • 你的意思是像SaveFileDialog吗?
  • @OneFineDay:是的,你知道吗?

标签: vb.net visual-studio crystal-reports


【解决方案1】:

提示用户保存位置是您应用程序的一部分 - this related question 提供了一些有关如何执行此操作的答案。然后,您只需提供从对话框到 Crystal Reports 导出 API 的路径,以便将其保存到该位置。

【讨论】:

  • 谢谢。找到了类似HttpRespone的方式,但是没有找到
【解决方案2】:

这是我项目中的部分代码。我希望它有所帮助。

    Dim saveFileDialog1 As New SaveFileDialog()
    'saveFileDialog1.InitialDirectory = My.Computer.FileSystem.CurrentDirectory

    saveFileDialog1.Filter = "PDF files (*.PDF)|*.PDF"
    saveFileDialog1.FilterIndex = 1
    saveFileDialog1.RestoreDirectory = True
    If saveFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
        Try
            'Here is where you write the file 

        Catch Ex As Exception
            'MessageBox.Show("Cannot read file from disk. Original error: " & Ex.Message)

        Finally
            ' Check this again, since we need to make sure we didn't throw an exception on open. 
        End Try
    End If

【讨论】:

    猜你喜欢
    • 2019-04-30
    • 1970-01-01
    • 1970-01-01
    • 2017-01-20
    • 1970-01-01
    • 2017-11-24
    • 1970-01-01
    • 2016-04-08
    • 1970-01-01
    相关资源
    最近更新 更多