我正在使用ReportViewer,我正在寻找出口的结果。我想得到一个关于导出细节(文件名和文件路径)的回调。我google了,只能找到reportviewer.export事件,但这是在导出之前触发的事件。之后我正在寻找一些东西。任何提示将非常感谢。
答案 0 :(得分:1)
您可以实施自己的ReportExport
事件,以便在导出后添加功能。
这是VB.NET中的一个例子:
Private Sub ReportViewer1_ReportExport(sender As Object, e As Microsoft.Reporting.WinForms.ReportExportEventArgs) Handles ReportViewer1.ReportExport
e.Cancel = True 'stop the default ReportExport event
Dim strExtension As String = ""
Select Case UCase(e.Extension.Name)
Case "PDF"
strExtension = ".pdf"
Case "EXCEL"
strExtension = ".xls"
Case "WORD"
strExtension = ".doc"
End Select
Dim dlgSaveFile As New System.Windows.Forms.SaveFileDialog
dlgSaveFile.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
dlgSaveFile.Filter = e.Extension.LocalizedName + " (*" + strExtension + ")|*" + strExtension + "|All files(*.*)|*.*"
If dlgSaveFile.ShowDialog(Me) = Windows.Forms.DialogResult.OK Then
Me.ReportViewer1.ExportDialog(e.Extension, e.DeviceInfo, dlgSaveFile.FileName)
'add here your functionality, for example a simple MsgBox that display where file is saved
MsgBox("File saved in: " & dlgSaveFile.FileName)
End If
End Sub