- 2026-04-09 1.1.8 Se añade la clase tsNotificacionesClient
- 2026-04-09 1.1.7 Se añade la clase Excel
This commit is contained in:
38
Excel.vb
Normal file
38
Excel.vb
Normal file
@@ -0,0 +1,38 @@
|
||||
Imports System.IO
|
||||
|
||||
Public Class Excel
|
||||
Public Shared Sub IEnumerableAExcel(Of t)(Datos As IEnumerable(Of t), Fichero As String)
|
||||
Dim wb As New ClosedXML.Excel.XLWorkbook
|
||||
Dim dt = Extensiones.IEnumerableExtensions.CopyToDataTable(Of t)(Datos)
|
||||
wb.AddWorksheet(dt)
|
||||
wb.SaveAs(Fichero)
|
||||
End Sub
|
||||
|
||||
Public Shared Sub IEnumerableAExcel(Of t)(Datos As List(Of t), Fichero As String)
|
||||
Dim wb As New ClosedXML.Excel.XLWorkbook
|
||||
Dim dt = Extensiones.IEnumerableExtensions.CopyToDataTable(Of t)(Datos)
|
||||
wb.AddWorksheet(dt)
|
||||
wb.SaveAs(Fichero)
|
||||
End Sub
|
||||
Public Shared Function IEnumerableAExcel(Of t)(Datos As List(Of t)) As Byte()
|
||||
Dim wb As New ClosedXML.Excel.XLWorkbook
|
||||
Dim dt = Extensiones.IEnumerableExtensions.CopyToDataTable(Of t)(Datos)
|
||||
wb.AddWorksheet(dt)
|
||||
Dim ms As New MemoryStream
|
||||
wb.SaveAs(ms)
|
||||
ms.Position = 0
|
||||
Return ms.ToArray
|
||||
End Function
|
||||
Public Shared Function ListaIEnumerableAExcel(Of t)(Datos As List(Of List(Of t)), NombreTablas As List(Of String)) As Byte()
|
||||
Dim wb As New ClosedXML.Excel.XLWorkbook
|
||||
For i = 0 To Datos.Count - 1
|
||||
Dim tabla = Datos(i)
|
||||
Dim dt = Extensiones.IEnumerableExtensions.CopyToDataTable(Of t)(tabla)
|
||||
wb.AddWorksheet(dt, NombreTablas(i))
|
||||
Next
|
||||
Dim ms As New MemoryStream
|
||||
wb.SaveAs(ms)
|
||||
ms.Position = 0
|
||||
Return ms.ToArray
|
||||
End Function
|
||||
End Class
|
||||
Reference in New Issue
Block a user