set SaveFileDialog to save crystal report
I have a button a form which opens a save file dialog and saves images.
I now want to add functionality to the button so that it saves a crystal report that im viewing in a crystalreportviewer which is also on my form.
How can I do this, ive tried accessing the report source property of the viewer but I cannot set the save as I have done with the .gif etc.
Here is my code, anyone got a solution
Private Sub Button2_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button2.Click
' Displays a SaveFileDialog so the user can save the Image
' assigned to Button2.
Dim saveFileDialog1 As New SaveFileDialog
saveFileDialog1.Filter = "JPeg Image|*.jpg|Bitmap Image|*.bmp|Gif Image|*.gif|All files (*.*)|*.*"""
saveFileDialog1.Title = "Save an Image File"
saveFileDialog1.ShowDialog()
Dim rptname As String
rptname = Me.CrystalReportViewer1.ReportSource
' If the file name is not an empty string open it for saving.
If saveFileDialog1.FileName <> "" Then
' Saves the Image via a FileStream created by the OpenFile method.
Dim fs As System.IO.FileStream = CType _
(saveFileDialog1.OpenFile(), System.IO.FileStream)
' Saves the Image in the appropriate ImageFormat based upon the
' file type selected in the dialog box.
' NOTE that the FilterIndex property is one-based.
Select Case saveFileDialog1.FilterIndex
Case 1
Me.button2.Image.Save(fs, _
System.Drawing.Imaging.ImageFormat.Jpeg)
Case 2
Me.button2.Image.Save(fs, _
System.Drawing.Imaging.ImageFormat.Bmp)
Case 3
Me.Button2.Image.Save(fs, _
System.Drawing.Imaging.ImageFormat.Gif)
Case 4
' I want to save the report being viewed in CrystalReportViewer1 as excel.
End Select
fs.Close()
End If
End Sub
__________________
Thank You
|