Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Protected Sub btn_Exportar_Click(sender As Object, e As EventArgs) Handles btn_Exportar.Click
- Dim warnings As Warning()
- Dim streamids As String()
- Dim mimeType As String
- Dim encoding As String
- Dim extension As String
- Dim filename As String
- 'Consulta que devuelve el dataset con los datos en pantalla
- Dim ds As DataSet = clsusr.ExportarUsr(GrillaUsuario, txtUsr_log.Text.Trim(), txtNit_Usr.Text.Trim(), txtNom_Ape.Text.Trim(), txtNit_Emp.Text.Trim(), txtRac_soc.Text.Trim())
- Dim ds2 As New DataTable
- 'le asigno la tabla 0 del dataset al datatable
- ds2 = ds.Tables(0)
- 'le asigno la fuente al reporte
- Dim datos As New ReportDataSource("DataSet1", ds2)
- 'le indico donde esta la ruta del reporte a exportar
- ReportViewer1.LocalReport.ReportPath = ("Reportes\ReporteMantencionUsrIe.rdlc")
- reportViewer1.ProcessingMode = ProcessingMode.Local
- ReportViewer1.LocalReport.DataSources.Clear()
- 'le agrego el datataset al reporte
- reportViewer1.LocalReport.DataSources.Add(New ReportDataSource("DataSet1", ds.Tables(0)))
- reportViewer1.LocalReport.Refresh()
- 'creo un byte con la extension deseada
- Dim bytes As Byte() = ReportViewer1.LocalReport.Render("EXCELOPENXML", Nothing, mimeType, Encoding, extension, streamids, warnings)
- 'filename = String.Format("{0}.{1}", "BitacoraWeb_usuario_" & txtusr.Text & "_" & txtdesde.Text.Replace("/", "-") & "_" & txtHasta.Text.Replace("/", "-"), "xlsx")
- 'le asigno un nombre al archivo
- filename = String.Format("Busqueda_Usuarios_Empresa", "xlsx")
- Response.ClearHeaders()
- Response.Clear()
- Response.AddHeader("Content-Disposition", Convert.ToString("attachment;filename=") & filename)
- Response.ContentType = mimeType
- Response.BinaryWrite(bytes)
- Response.Flush()
- Response.[End]()
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement