Exel anexos horizontales, AF

This commit is contained in:
Rakcsle Supertramp
2020-09-02 12:00:59 -07:00
parent a7bd0a3798
commit d5a4849d27
14 changed files with 1213 additions and 365 deletions

View File

@@ -10,6 +10,23 @@
<asp:Content ID="Content4" ContentPlaceHolderID="HB" runat="Server">
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="H" runat="Server">
<asp:UpdatePanel runat="server" UpdateMode="Conditional" ID="UpAcciones">
<ContentTemplate>
<li>
<asp:LinkButton ID="LnkExportar" runat="server" Visible="false"><i class="fa fa-ad-excel"></i> Generar Excel</asp:LinkButton>
</li>
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="LnkExportar" />
</Triggers>
</asp:UpdatePanel>
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="HA" runat="Server">
</asp:Content>

View File

@@ -133,12 +133,24 @@ Partial Class Contabilidad2_RepAnexoCatalogoAnual
'RegistraScript($"LimpiaCeros({DdlDivisor.SelectedValue});")
RegistraScript($"LimpiaCeros();")
Conta.Dispose()
End Sub
Conta.Dispose()
If GvAnual.Rows.Count > 0 Then
LnkExportar.Visible = True
UpAcciones.Update()
End If
End Sub
#End Region
#Region " GV ROW DATABOUND "
Protected Sub GvAnual_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvAnual.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
@@ -150,9 +162,25 @@ Partial Class Contabilidad2_RepAnexoCatalogoAnual
e.Row.Style.Add("text-indent", $"{e.Row.DBCampo("Level").ToString.ToEntero * 2}em")
End If
End Sub
End Sub
Private Sub LnkExportar_Click(sender As Object, e As EventArgs) Handles LnkExportar.Click
Dim SubProyecto As String = ""
If DdlSubProyecto.SelectedValue.ToEntero > 0 Then
SubProyecto = DdlSubProyecto.SelectedItem.Text
End If
GvAnual.ExportToExcelGembox("AnexoCatálogoAnual", UsuarioActual, $"01/01/{DdlEjercicio.SelectedValue}", $"31/12/{DdlEjercicio2.SelectedValue}", "Anexo del Catálogo - Anual", SubProyecto, DdlDivisor.SelectedValue.ToEntero, DatoTituloExtra:=$"Periodo {DdlPeriodo.SelectedItem.Text}")
End Sub
Public Overrides Sub VerifyRenderingInServerForm(ByVal control As Control)
End Sub
#End Region
End Class

View File

@@ -11,6 +11,18 @@
<asp:Content ID="Content4" ContentPlaceHolderID="HB" runat="Server">
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="H" runat="Server">
<asp:UpdatePanel runat="server" UpdateMode="Conditional" ID="UpAcciones">
<ContentTemplate>
<li>
<asp:LinkButton ID="LnkExportar" runat="server" Visible="false"><i class="fa fa-ad-excel"></i> Generar Excel</asp:LinkButton>
</li>
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="LnkExportar" />
</Triggers>
</asp:UpdatePanel>
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="HA" runat="Server">
</asp:Content>

View File

@@ -112,6 +112,14 @@ Partial Class Contabilidad2_RepAnexoCatalogoCC
Else
GvCC.DataSource = Nothing
End If
If GvCC.Rows.Count > 0 Then
LnkExportar.Visible = True
UpAcciones.Update()
End If
RegistraScript($"LimpiaCeros({DdlDivisor.SelectedValue});")
@@ -132,9 +140,22 @@ Partial Class Contabilidad2_RepAnexoCatalogoCC
e.Row.Style.Add("text-indent", $"{e.Row.DBCampo("Level").ToString.ToEntero * 2}em")
End If
End Sub
End Sub
#End Region
Private Sub LnkExportar_Click(sender As Object, e As EventArgs) Handles LnkExportar.Click
Dim SubProyecto As String = ""
If DdlSubProyecto.SelectedValue.ToEntero > 0 Then
SubProyecto = DdlSubProyecto.SelectedItem.Text
End If
GvCC.ExportToExcelGembox("AnexoCatálogoMensual", UsuarioActual, $"01/01/{DdlEjercicio.SelectedValue}", $"31/12/{DdlEjercicio.SelectedValue}", "Anexo del Catálogo - Mensual", SubProyecto, DdlDivisor.SelectedValue.ToEntero, DatoTituloExtra:=$"Periodo {DdlPeriodo.SelectedItem.Text}")
End Sub
Public Overrides Sub VerifyRenderingInServerForm(ByVal control As Control)
End Sub
End Class

View File

@@ -16,6 +16,21 @@
<asp:Content ID="Content4" ContentPlaceHolderID="HB" runat="Server">
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="H" runat="Server">
<asp:UpdatePanel runat="server" UpdateMode="Conditional" ID="UpAcciones">
<ContentTemplate>
<li>
<asp:LinkButton ID="LnkExportar" runat="server" Visible="false"><i class="fa fa-ad-excel"></i> Generar Excel</asp:LinkButton>
</li>
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="LnkExportar" />
</Triggers>
</asp:UpdatePanel>
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="HA" runat="Server">
</asp:Content>

View File

@@ -79,7 +79,15 @@ Partial Class Contabilidad2_RepAnexoCatalogoMensual
GvMensual2.DataSource = Nothing
End If
GvMensual2.DataBind()
UpMensual.Update()
UpMensual.Update()
If GvMensual2.Rows.Count > 0 Then
LnkExportar.Visible = True
UpAcciones.Update()
End If
RegistraScript($"LimpiaCeros();")
Conta.Dispose()
@@ -99,9 +107,22 @@ Partial Class Contabilidad2_RepAnexoCatalogoMensual
e.Row.Style.Add("text-indent", $"{e.Row.DBCampo("Level").ToString.ToEntero * 2}em")
End If
End Sub
End Sub
#End Region
Private Sub LnkExportar_Click(sender As Object, e As EventArgs) Handles LnkExportar.Click
Dim SubProyecto As String = ""
If DdlSubProyecto.SelectedValue.ToEntero > 0 Then
SubProyecto = DdlSubProyecto.SelectedItem.Text
End If
GvMensual2.ExportToExcelGembox("AnexoCatálogoMensual", UsuarioActual, $"01/01/{DdlEjercicio.SelectedValue}", $"31/12/{DdlEjercicio.SelectedValue}", "Anexo del Catálogo - Mensual", SubProyecto, DdlDivisor.SelectedValue.ToEntero, DatoTituloExtra:=$"Periodo {DdlPeriodo.SelectedItem.Text}")
End Sub
Public Overrides Sub VerifyRenderingInServerForm(ByVal control As Control)
End Sub
End Class

View File

@@ -174,6 +174,22 @@ Partial Class Contabilidad_RepEstadoResultadosHorizontal
End Set
End Property
Private Property CountDinamicoAnual As Integer
Get
If ViewState("CountDinamicoAnual") Is Nothing Then
Return 0
Else
Return ViewState("CountDinamicoAnual").ToString.ToEntero
End If
End Get
Set(value As Integer)
ViewState("CountDinamicoAnual") = value
End Set
End Property
#End Region
#Region " S U B P R O Y E C T O H O R I Z O N T A L "
@@ -230,6 +246,23 @@ Partial Class Contabilidad_RepEstadoResultadosHorizontal
End Property
Private Property CountDinamicoSubProyecto As Integer
Get
If ViewState("CountDinamicoSubProyecto") Is Nothing Then
Return 0
Else
Return ViewState("CountDinamicoSubProyecto").ToString.ToEntero
End If
End Get
Set(value As Integer)
ViewState("CountDinamicoSubProyecto") = value
End Set
End Property
#End Region
@@ -1081,6 +1114,17 @@ Partial Class Contabilidad_RepEstadoResultadosHorizontal
Dim IndexGv As Integer = 1
Dim IndexMax As Integer = 1
Dim IDX_LIMPIAR As Integer = 1
For IDX_LIMPIAR = 1 To 25
GvIngresosAnualH.Columns(IDX_LIMPIAR).Visible = False
GvGastosAnualH.Columns(IDX_LIMPIAR).Visible = False
GvTotalesAnualH.Columns(IDX_LIMPIAR).Visible = False
Next
If DtIngresosAnualH.Rows.Count > 0 Then
@@ -1142,6 +1186,7 @@ Partial Class Contabilidad_RepEstadoResultadosHorizontal
Row.Item("PorcentajeAcumulado") = "100.00"
Row.Item("CtaMayor") = -1
Row.Item("CountDinamico") = DtGastosAnualH.MAX("CountDinamico")
CountDinamicoAnual = DtGastosAnualH.MAX("CountDinamico").ToEntero
DtIngresosAnualH.Rows.Add(Row)
Else
Row.Item("Nombre") = "TOTAL INGRESOS "
@@ -1441,9 +1486,10 @@ Partial Class Contabilidad_RepEstadoResultadosHorizontal
'34
Dim IDX_LIMPIAR As Integer = 1
For IDX_LIMPIAR = 1 To 34
For IDX_LIMPIAR = 1 To 35
CType(GvIngresosSubProyectoH.Columns(IDX_LIMPIAR), BoundField).DataField = Nothing
CType(GvIngresosSubProyectoH.Columns(IDX_LIMPIAR), BoundField).HeaderText = ""
GvIngresosSubProyectoH.Columns(IDX_LIMPIAR).Visible = False
Next
@@ -1499,6 +1545,7 @@ Partial Class Contabilidad_RepEstadoResultadosHorizontal
Row.Item("PorcentajeAcumulado") = "100.00"
Row.Item("CtaMayor") = -1
Row.Item("CountDinamico") = DtIngresosSubProyectoH.MAX("CountDinamico")
CountDinamicoSubProyecto = DtIngresosSubProyectoH.MAX("CountDinamico").ToEntero
DtIngresosSubProyectoH.Rows.Add(Row)
Else
Row.Item("Nombre") = "TOTAL INGRESOS "
@@ -1692,6 +1739,7 @@ Partial Class Contabilidad_RepEstadoResultadosHorizontal
If e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble < 0 Then
e.Row.FCHyperLink("HLAnterior").ForeColor = Drawing.Color.Red
End If
End If
End Sub
@@ -1751,7 +1799,7 @@ Partial Class Contabilidad_RepEstadoResultadosHorizontal
ExportToExcelG(GvIngresosAnualH, GvGastosAnualH, TMesT1, "Reporte_Anual_Horizontal", UsuarioActual, "Anual Horizontal", Gv3:=GvTotalesAnualH)
ElseIf Tab.ActiveTabIndex = 3 AndAlso GvIngresosSubProyectoH.Rows.Count > 0 Then
ExportToExcelG(GvIngresosSubProyectoH, GvGastosSubProyectoH, TMesT1, "Reporte_Proyecto_Horizontal", UsuarioActual, "Proyecto Horizontal", Gv3:=GvTotalesSubProyectoH, EsPorSubProtyecto:=True)
ExportToExcelG(GvIngresosSubProyectoH, GvGastosSubProyectoH, TMesT1, "Reporte_Proyecto_Horizontal", UsuarioActual, $"{LblSubProyecto.Text} Horizontal", Gv3:=GvTotalesSubProyectoH, EsPorSubProtyecto:=True)
End If
End Sub
@@ -1829,28 +1877,21 @@ Partial Class Contabilidad_RepEstadoResultadosHorizontal
HtmlCompleto = Regex.Replace(HtmlCompleto, "\<[\/]*a[^\>]*\>", "")
Dim asd As String = ""
Dim htmlStream5 = New MemoryStream(options.Encoding.GetBytes(HtmlCompleto))
GemBox.Spreadsheet.SpreadsheetInfo.SetLicense("ESWN-4QFD-26JF-1SZ8")
GemBox.Spreadsheet.SpreadsheetInfo.SetLicense(SerialGemBoxSpreadsheet)
Dim excel As GemBox.Spreadsheet.ExcelFile
'Dim options = GemBox.Spreadsheet.LoadOptions.HtmlDefault
'Using htmlStream = New MemoryStream(options.Encoding.GetBytes(sw.ToString()))
' excel = GemBox.Spreadsheet.ExcelFile.Load(htmlStream, options)
excel = GemBox.Spreadsheet.ExcelFile.Load(htmlStream5, options)
If Usuario IsNot Nothing Then
Dim TotalRowHeader As Integer = 8
Dim TotalRowFooter As Integer = 2
Dim worksheet = excel.Worksheets(0)
worksheet.Rows.InsertEmpty(0, TotalRowHeader)
Dim celdasConTexto = worksheet.GetUsedCellRange(True)
@@ -1865,15 +1906,6 @@ Partial Class Contabilidad_RepEstadoResultadosHorizontal
RangoNombreEmpresa.Style.VerticalAlignment = GemBox.Spreadsheet.VerticalAlignmentStyle.Center
'Dim RangoFiltros = worksheet.Cells.GetSubrangeAbsolute(6, celdasConTexto.FirstColumnIndex, 6, celdasConTexto.LastColumnIndex)
'RangoFiltros.Merged = True
'RangoFiltros.Value = "Filtros"
'RangoFiltros.Style.Font.Size = 15 * 20
'RangoFiltros.Style.Font.Name = "Calibri Light"
'RangoFiltros.Style.HorizontalAlignment = GemBox.Spreadsheet.HorizontalAlignmentStyle.Left
'RangoFiltros.Style.VerticalAlignment = GemBox.Spreadsheet.VerticalAlignmentStyle.Center
Dim RangoTitulo = worksheet.Cells.GetSubrangeAbsolute(3, celdasConTexto.FirstColumnIndex, 3, celdasConTexto.LastColumnIndex)
RangoTitulo.Merged = True
RangoTitulo.Value = Titulo
@@ -1882,7 +1914,27 @@ Partial Class Contabilidad_RepEstadoResultadosHorizontal
RangoTitulo.Style.HorizontalAlignment = GemBox.Spreadsheet.HorizontalAlignmentStyle.Center
RangoTitulo.Style.VerticalAlignment = GemBox.Spreadsheet.VerticalAlignmentStyle.Center
Dim RangoFechas = worksheet.Cells.GetSubrangeAbsolute(4, celdasConTexto.FirstColumnIndex, 4, celdasConTexto.LastColumnIndex)
RangoFechas.Merged = True
RangoFechas.Value = $"Fechas: {FechaIMes} a {FechaFMes}"
RangoFechas.Style.Font.Size = 15 * 20
RangoFechas.Style.Font.Name = "Calibri Light"
RangoFechas.Style.HorizontalAlignment = GemBox.Spreadsheet.HorizontalAlignmentStyle.Center
RangoFechas.Style.VerticalAlignment = GemBox.Spreadsheet.VerticalAlignmentStyle.Center
If EsPorSubProtyecto And DdlSubproyecto.SelectedValue.ToEntero > 0 Then
Dim RangoSubProyecto = worksheet.Cells.GetSubrangeAbsolute(5, celdasConTexto.FirstColumnIndex, 5, celdasConTexto.LastColumnIndex)
RangoSubProyecto.Merged = True
RangoSubProyecto.Value = DdlSubproyecto.SelectedItem.Text
RangoSubProyecto.Style.Font.Size = 20 * 20
RangoSubProyecto.Style.Font.Name = "Calibri Light"
RangoSubProyecto.Style.HorizontalAlignment = GemBox.Spreadsheet.HorizontalAlignmentStyle.Center
RangoSubProyecto.Style.VerticalAlignment = GemBox.Spreadsheet.VerticalAlignmentStyle.Center
End If
For i = celdasConTexto.FirstColumnIndex To celdasConTexto.LastColumnIndex
worksheet.Rows(8).Cells(i).Style.Font.Size = 12 * 20
worksheet.Rows(8).Cells(i).Style.HorizontalAlignment = GemBox.Spreadsheet.HorizontalAlignmentStyle.Center
worksheet.Rows(8).Cells(i).Style.VerticalAlignment = GemBox.Spreadsheet.VerticalAlignmentStyle.Center
@@ -1929,10 +1981,30 @@ Partial Class Contabilidad_RepEstadoResultadosHorizontal
End Using
End If
End If
'End Using
'htw.Dispose()
For I = celdasConTexto.FirstColumnIndex To celdasConTexto.LastColumnIndex
If I > 0 Then
If DdlDivisor.SelectedValue.ToEntero = 1 Then
worksheet.Columns(I + 1).Style.NumberFormat = "#,##0.00"
Else
worksheet.Columns(I + 1).Style.NumberFormat = "#,##"
End If
Try
worksheet.Columns(I).AutoFit(1)
Catch ex As Exception
End Try
End If
Next
End If
excel.Save(HttpContext.Current.Response, $"{NombreArchivoXLSx}.xlsx")