Rep Personal DIM saltos delinea en titulos de cabecera

This commit is contained in:
Oscar Irigoyen
2023-06-20 14:57:19 -07:00
parent fd5962a6e7
commit 08b8d3de9e
2 changed files with 1044 additions and 529 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -85,6 +85,8 @@ Partial Class Nomina_RepPersonalDIM
GvDatos.DataBind() GvDatos.DataBind()
UpAcciones.Update()
UpGvCargaDatos.Update()
End Sub End Sub
@@ -105,38 +107,44 @@ Partial Class Nomina_RepPersonalDIM
End Sub End Sub
Protected Sub LnkDescargaArchivo_Click(ByVal sender As Object, ByVal e As EventArgs) Handles LnkDescargaArchivo.Click Protected Sub LnkDescargaArchivo_Click(ByVal sender As Object, ByVal e As EventArgs) Handles LnkDescargaArchivo.Click
Dim tabla As DataTable = Dt_Datos ' Reemplaza esto con tu método para obtener la tabla Dim tabla As DataTable = Dt_Datos
Dim contenido As String = ConvertirTablaATexto(tabla) Dim contenidoBytes As Byte() = Encoding.UTF8.GetBytes(ConvertirTablaATexto(tabla))
' Guardar el archivo en el servidor Using memoryStream As New MemoryStream(contenidoBytes)
Dim nombreArchivo As String = "tabla.txt" Response.Clear()
Dim rutaArchivo As String = Server.MapPath("~/Descargas/" & nombreArchivo) Response.ContentType = "text/plain"
File.WriteAllText(rutaArchivo, contenido) Response.AddHeader("Content-Disposition", $"attachment; filename=RepPersonalDIM{DdlEjercicio.SelectedItem.Text}.txt")
memoryStream.WriteTo(Response.OutputStream)
End Using
' Descargar el archivo
Response.ContentType = "text/plain"
Response.AppendHeader("Content-Disposition", "attachment; filename=" & nombreArchivo)
Response.TransmitFile(rutaArchivo)
Response.End() Response.End()
End Sub End Sub
Public Function ConvertirTablaATexto(ByVal tabla As DataTable) As String Public Function ConvertirTablaATexto(ByVal tabla As DataTable) As String
'Dim sb As New StringBuilder()
'For Each GvRow As GridViewRow In GvDatos.Rows
' For Each GvCell As TableCell In GvRow.Cells
' sb.Append(GvCell.ID & "|")
' Next
' sb.AppendLine()
'Next
'Return sb.ToString()
Dim sb As New StringBuilder() Dim sb As New StringBuilder()
For Each gvRow As GridViewRow In GvDatos.Rows
For Each fila As DataRow In tabla.Rows For Each gvCell As TableCell In gvRow.Cells
For i As Integer = 0 To tabla.Columns.Count - 1 Dim columnIndex As Integer = gvRow.Cells.GetCellIndex(gvCell)
sb.Append(fila(i).ToString()) Dim rowIndex As Integer = gvRow.RowIndex
Dim cellID As String = "cell_" & rowIndex.ToString() & "_" & columnIndex.ToString()
If i < tabla.Columns.Count - 1 Then sb.Append(gvRow.Cells(columnIndex).Controls(0).ClientID & "|")
sb.Append("|") ' Agrega el separador de pipes
End If
Next Next
sb.AppendLine()
sb.AppendLine() ' Agrega un salto de línea al final de cada fila
Next Next
Return sb.ToString() Return sb.ToString()
End Function End Function
#End Region #End Region
@@ -153,17 +161,17 @@ Partial Class Nomina_RepPersonalDIM
cell = New TableHeaderCell() cell = New TableHeaderCell()
cell.ColumnSpan = 16 cell.ColumnSpan = 18
cell.Text = "ANEXO 1 PAGOS POR SEPARACION ->" cell.Text = "ANEXO 1 PAGOS POR SEPARACION ->"
cell.HorizontalAlign = HorizontalAlign.Left cell.HorizontalAlign = HorizontalAlign.Left
row.Controls.Add(cell) row.Controls.Add(cell)
cell = New TableHeaderCell() 'cell = New TableHeaderCell()
cell.ColumnSpan = 2 'cell.ColumnSpan = 2
cell.Text = " ANEXO 1 ASIM SAL-> " 'cell.Text = " ANEXO 1 ASIM SAL-> "
cell.HorizontalAlign = HorizontalAlign.Left 'cell.HorizontalAlign = HorizontalAlign.Left
row.Controls.Add(cell) 'row.Controls.Add(cell)
cell = New TableHeaderCell() cell = New TableHeaderCell()