Simple.
Private Sub btnLoadReport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoadReport.Click
Try
vLoadDataSet() 'load the datatable with the records
Dim pr1 As New ParameterDiscreteValue
pr1.Value = dtDateFrom.Value.ToShortDateString
Dim pr2 As New ParameterDiscreteValue
pr2.Value = dtDateTo.Value.ToShortDateString
Dim pr3 As New ParameterDiscreteValue
pr3.Value = txtTitle.Text
Dim crSource As New RepMcLennanCCCriminalDocket
crSource.SetDataSource(dtReport)
crSource.SetParameterValue("pFrom", pr1)
crSource.SetParameterValue("pTo", pr2)
crSource.SetParameterValue("pTitle", pr3)
crViewer.ReportSource = crSource
crViewer.Refresh()
crViewer.Visible = True
crViewer.Show()
''here set the export
crSource.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile
crSource.ExportOptions.ExportFormatType = ExportFormatType.ExcelRecord
Dim objExcelOptions As ExcelFormatOptions = New ExcelFormatOptions
objExcelOptions.ExcelTabHasColumnHeadings = True
objExcelOptions.ExcelUseConstantColumnWidth = False
crSource.ExportOptions.FormatOptions = objExcelOptions
Dim objOptions As DiskFileDestinationOptions = New DiskFileDestinationOptions
objOptions.DiskFileName = "SettingList.xls"
crSource.ExportOptions.DestinationOptions = objOptions
''here export
crSource.Export()
''here open the excel
Process.Start("EXCEL.EXE", """SettingList.xls""")
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
End Sub
No hay comentarios.:
Publicar un comentario