Código de Visual Basic.NET - Anexar un reporte en Crystal Report

Imágen de perfil
Val: 50
Ha disminuido su posición en 5 puestos en Visual Basic.NET (en relación al último mes)
Gráfica de Visual Basic.NET

Anexar un reporte en Crystal Reportgráfica de visualizaciones


Visual Basic.NET

Actualizado el 2 de Junio del 2016 por Hugo (2 códigos) (Publicado el 27 de Mayo del 2016)
17.181 visualizaciones desde el 27 de Mayo del 2016
Crear un reporte en VB.net 2010 con Crystal Report

Crea un DATASET, presionar ADD

1

Creara el DATASET

2

Seleccionar la table y arrastrarla para que realice la conexión

3

Adicionar CRYSTAL REPORT, presionar el botón ADD

4

Deja USING THE REPORT WIZARD/STANDARD, presiona OK

5

Se visualizara la pantalla del wizard, selecciona la table y pasarla a SELECTED TABLES, presionar SIGUIENTE

6

Seleccionar los campos que aparecerán en el reporte, presionar siguiente

7

En caso de querer agruparlo seleccionar los campos, presionar siguiente

8

En caso de querer hacer una selección de campos con formula, presionar siguiente

9

Seleccionar algún estilo para el reporte, presionar Finalizar

10

Por último acomodar los campos y titulo

11

Crear un form donde llamaremos el reporte, presionar ADD

12

Arrastramos un CRYSTALREPORTVIEWER

13

Seleccionamos las propiedades del CRYSTALREPORTVIEWER1 , en el REPORTSOURCE seleccionamos el reporte creado y creara un REPORTDOCUMENT

14

Dentro de la form que llama el reporte copiar el código:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Imports System.Data.SqlClient
Imports System.Data
Private Sub ingresos_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
	Cnn.open
	Try
		Dim Ds As New dsingresos
		Dim Da As New SqlClient.SqlDataAdapter("Select * From TABLA " & _
		"where FECHA_INGRESO >= '" & CAMPO_INGRESO.DateTimePicker11.Text & "' and FECHA_INGRESO <= '" & CAMPO_INGRESO.DateTimePicker22.Text & "' order by FECHA_INGRESO", Cnn)
		Da.Fill(Ds, "TABLA")
		'Mandar los datos al dataSet y muestralos
		'se tiene que crear forzosamente esta instancia para poder pasar
		'parametros...
		Dim Reporte As New NOMBRE_REPORTE
		Reporte.SetDataSource(Ds)
		Reporte.SummaryInfo.ReportTitle = "TITULO DE MI REPORTE " & Today
		Reporte.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Landscape
		Me.CrystalReportViewer1.ReportSource = Reporte
	Catch ex As Exception
		MessageBox.Show(ex.ToString)
	End Try
End Sub
El código se copia en el load de la form, este código es para enviar un rango de fechas a imprimir.
Se crea una siguiente form donde se podrán 4 DateTimePicker

15

En el botòn GENERAR REPORTE copiar el siguiente còdigo:
1
2
3
4
5
6
7
8
9
10
11
12
Imports system.DateTime
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
	'Se asigna al 11 y 22 para que no cambie el fomato de fechas
	DateTimePicker11.Text = DateTimePicker1.Text
	DateTimePicker22.Text = DateTimePicker2.Text
	'Cambia formato de fechas para 11 y 22
	DateTimePicker11.CustomFormat = "yyyyMMdd"
	DateTimePicker11.Format = DateTimePickerFormat.Custom
	DateTimePicker22.CustomFormat = "yyyyMMdd"
	DateTimePicker22.Format = DateTimePickerFormat.Custom
	My.Forms.ingresos.ShowDialog()
End Sub

Requerimientos

VS 2010
estrellaestrellaestrellaestrellaestrella(3)

Actualizado el 30 de Mayo del 2016 (Publicado el 27 de Mayo del 2016)gráfica de visualizaciones de la versión: VS 2010
17.182 visualizaciones desde el 27 de Mayo del 2016
estrellaestrellaestrellaestrellaestrella
estrellaestrellaestrellaestrella
estrellaestrellaestrella
estrellaestrella
estrella

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
'Dentro de la form que llama el reporte copiar el código:
Imports System.Data.SqlClient
Imports System.Data
    Private Sub ingresos_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Cnn.open
        Try
            Dim Ds As New dsingresos
            Dim Da As New SqlClient.SqlDataAdapter("Select * From TABLA " & _
            "where FECHA_INGRESO >= '" & CAMPO_INGRESO.DateTimePicker11.Text & "' and FECHA_INGRESO <= '" & CAMPO_INGRESO.DateTimePicker22.Text & "' order by FECHA_INGRESO", Cnn)
            Da.Fill(Ds, "TABLA")
            'Mandar los datos al dataSet y muestralos
            'se tiene que crear forzosamente esta instancia para poder pasar
            'parametros...
            Dim Reporte As New NOMBRE_REPORTE
            Reporte.SetDataSource(Ds)
            Reporte.SummaryInfo.ReportTitle = "TITULO DE MI REPORTE " & Today
            Reporte.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Landscape
            Me.CrystalReportViewer1.ReportSource = Reporte
        Catch ex As Exception
            MessageBox.Show(ex.ToString)
        End Try
    End Sub
'El código se copia en el load de la form, este código es para enviar un rango de fechas a imprimir.
 
 
'En el botòn GENERAR REPORTE copiar el siguiente còdigo:
Imports system.DateTime
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        'Se asigna al 11 y 22 para que no cambie el fomato de fechas
        DateTimePicker11.Text = DateTimePicker1.Text
        DateTimePicker22.Text = DateTimePicker2.Text
        'Cambia formato de fechas para 11 y 22
        DateTimePicker11.CustomFormat = "yyyyMMdd"
        DateTimePicker11.Format = DateTimePickerFormat.Custom
        DateTimePicker22.CustomFormat = "yyyyMMdd"
        DateTimePicker22.Format = DateTimePickerFormat.Custom
        My.Forms.ingresos.ShowDialog()
    End Sub



Comentarios sobre la versión: VS 2010 (3)

Imágen de perfil
2 de Junio del 2016
estrellaestrellaestrellaestrellaestrella
perfecto, justo lo que buscaba, tratare de modificar a mi modo, gracias
Responder
Wiliam
10 de Julio del 2016
estrellaestrellaestrellaestrellaestrella
Ayuda como puedo crear un informe por cada empleado en un solo reportview
Responder
jorge
17 de Diciembre del 2022
estrellaestrellaestrellaestrellaestrella
Muchas gracias. Fue de gran ayuda esta información
Responder

Comentar la versión: VS 2010

Nombre
Correo (no se visualiza en la web)
Valoración
Comentarios...
CerrarCerrar
CerrarCerrar
Cerrar

Tienes que ser un usuario registrado para poder insertar imágenes, archivos y/o videos.

Puedes registrarte o validarte desde aquí.

Codigo
Negrita
Subrayado
Tachado
Cursiva
Insertar enlace
Imagen externa
Emoticon
Tabular
Centrar
Titulo
Linea
Disminuir
Aumentar
Vista preliminar
sonreir
dientes
lengua
guiño
enfadado
confundido
llorar
avergonzado
sorprendido
triste
sol
estrella
jarra
camara
taza de cafe
email
beso
bombilla
amor
mal
bien
Es necesario revisar y aceptar las políticas de privacidad

http://lwp-l.com/s3539