Estadísticas del código: Anexar un reporte en Crystal Report - Visual Basic.NET

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 Report


Visual Basic.NET

estrellaestrellaestrellaestrellaestrella(3)
Actualizado el 2 de Junio del 2016 por Hugo (2 códigos) (Publicado el 27 de Mayo del 2016)
17.288 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

247 visualizaciones durante los últimos 90 días


16
0