Cursor = Cursors.WaitCursor
Try If Not System.IO.Directory.Exists("C:\report") ThenSystem.IO.Directory.CreateDirectory(
"C:\report") End If Catch ex As ExceptionMsgBox(
"You have not sufficient rights to create folder. Please contact your Administrator.") Exit Sub End Try Dim strExportFile As String = "C:\report\Report.xls"rs.ExportOptions.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile
If strExportFile.ToUpper.EndsWith(".XLS") Thenrs.ExportOptions.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.Excel
ElseIf strExportFile.ToUpper.EndsWith(".PDF") Thenrs.ExportOptions.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat
End If If File.Exists(strExportFile) ThenstrExportFile =
"C:\report\Report_" & Date.Now.Day & Date.Now.Month & Date.Now.Year & "_" & Date.Now.Hour & Date.Now.Minute & Date.Now.Second & ".xls" End Ifrs.ExportOptions.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile
rs.ExportOptions.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.Excel
Dim objOptions As New CrystalDecisions.Shared.DiskFileDestinationOptionsobjOptions.DiskFileName = strExportFile
rs.ExportOptions.DestinationOptions = objOptions
rs.Export()
Application.DoEvents()
objOptions =
NothingCursor = Cursors.Default
MsgBox(
"Export Completed" & vbCrLf & vbCrLf & "Report Generated At : " & strExportFile)System.Diagnostics.Process.Start(strExportFile)
Catch ex As ExceptionCursor = Cursors.Default
MsgBox(
"Exception in Exporting Report " & ex.ToString) Exit Sub End Try
No comments:
Post a Comment