Revert "Exportar a excel con gembox RepAnomalias.aspx"

This reverts commit 4ec6164e04.
This commit is contained in:
2021-11-30 12:46:10 -07:00
parent 0a5d8d36e3
commit 9e13c48f0c
15 changed files with 1509 additions and 1721 deletions

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -269,7 +269,6 @@
<asp:Label ID="LblC" runat="server" Font-Size="6pt"></asp:Label> <asp:Label ID="LblC" runat="server" Font-Size="6pt"></asp:Label>
</ItemTemplate> </ItemTemplate>
</asp:TemplateField> </asp:TemplateField>
<asp:BoundField HeaderText="Clasificación" DataField="Clasificacion" ItemStyle-HorizontalAlign="Left" />
<asp:BoundField HeaderText="Proveedor" DataField="NombreComercial" ItemStyle-HorizontalAlign="Left" Visible="false" /> <asp:BoundField HeaderText="Proveedor" DataField="NombreComercial" ItemStyle-HorizontalAlign="Left" Visible="false" />
<asp:BoundField HeaderText="Código" DataField="Codigo" ItemStyle-HorizontalAlign="Left" /> <asp:BoundField HeaderText="Código" DataField="Codigo" ItemStyle-HorizontalAlign="Left" />
<asp:BoundField HeaderText="Producto" DataField="PS" ItemStyle-HorizontalAlign="Left" /> <asp:BoundField HeaderText="Producto" DataField="PS" ItemStyle-HorizontalAlign="Left" />
@@ -327,7 +326,6 @@
<asp:Label ID="LblC" runat="server" Font-Size="6pt"></asp:Label> <asp:Label ID="LblC" runat="server" Font-Size="6pt"></asp:Label>
</ItemTemplate> </ItemTemplate>
</asp:TemplateField> </asp:TemplateField>
<asp:BoundField HeaderText="Clasificación" DataField="Clasificacion" ItemStyle-HorizontalAlign="Left" />
<asp:BoundField HeaderText="Proveedor" DataField="NombreComercial" ItemStyle-HorizontalAlign="Left" Visible="false" /> <asp:BoundField HeaderText="Proveedor" DataField="NombreComercial" ItemStyle-HorizontalAlign="Left" Visible="false" />
<asp:BoundField HeaderText="Código" DataField="Codigo" ItemStyle-HorizontalAlign="Left" /> <asp:BoundField HeaderText="Código" DataField="Codigo" ItemStyle-HorizontalAlign="Left" />
<asp:BoundField HeaderText="Producto" DataField="PS" ItemStyle-HorizontalAlign="Left" /> <asp:BoundField HeaderText="Producto" DataField="PS" ItemStyle-HorizontalAlign="Left" />
@@ -378,7 +376,6 @@
<asp:Label ID="LblC" runat="server" Font-Size="6pt"></asp:Label> <asp:Label ID="LblC" runat="server" Font-Size="6pt"></asp:Label>
</ItemTemplate> </ItemTemplate>
</asp:TemplateField> </asp:TemplateField>
<asp:BoundField HeaderText="Clasificación" DataField="Clasificacion" ItemStyle-HorizontalAlign="Left" />
<asp:BoundField HeaderText="Proveedor" DataField="NombreComercial" ItemStyle-HorizontalAlign="Left" Visible="false" /> <asp:BoundField HeaderText="Proveedor" DataField="NombreComercial" ItemStyle-HorizontalAlign="Left" Visible="false" />
<asp:BoundField HeaderText="Código" DataField="Codigo" ItemStyle-HorizontalAlign="Left" /> <asp:BoundField HeaderText="Código" DataField="Codigo" ItemStyle-HorizontalAlign="Left" />
<asp:BoundField HeaderText="Producto" DataField="PS" ItemStyle-HorizontalAlign="Left" /> <asp:BoundField HeaderText="Producto" DataField="PS" ItemStyle-HorizontalAlign="Left" />
@@ -478,7 +475,6 @@
<asp:CheckBox ID="ChkPSFaltante" runat="server" /> <asp:CheckBox ID="ChkPSFaltante" runat="server" />
</ItemTemplate> </ItemTemplate>
</asp:TemplateField> </asp:TemplateField>
<asp:BoundField HeaderText="Clasificación" DataField="Clasificacion" ItemStyle-HorizontalAlign="Left" />
<asp:BoundField HeaderText="Proveedor" DataField="NombreComercial" ItemStyle-HorizontalAlign="Left" Visible="false" /> <asp:BoundField HeaderText="Proveedor" DataField="NombreComercial" ItemStyle-HorizontalAlign="Left" Visible="false" />
<asp:BoundField HeaderText="Código" DataField="Codigo" ItemStyle-HorizontalAlign="Left" /> <asp:BoundField HeaderText="Código" DataField="Codigo" ItemStyle-HorizontalAlign="Left" />
<asp:BoundField HeaderText="Producto" DataField="PS" ItemStyle-HorizontalAlign="Left" /> <asp:BoundField HeaderText="Producto" DataField="PS" ItemStyle-HorizontalAlign="Left" />

View File

@@ -1,7 +1,5 @@
Imports System.Data Imports System.Data
Imports System.IO
Imports Extensiones Imports Extensiones
Imports GemBox.Spreadsheet
Imports Microsoft.Reporting.WebForms Imports Microsoft.Reporting.WebForms
Partial Class Inventarios_RepAnomalias Partial Class Inventarios_RepAnomalias
@@ -274,15 +272,15 @@ Partial Class Inventarios_RepAnomalias
DVGrupos.Visible = True DVGrupos.Visible = True
If DdlGPO.SelectedValue.ToEntero = 2 Then If DdlGPO.SelectedValue.ToEntero = 2 Then
GvGrupos.Columns(4).Visible = False
GvGrupos.Columns(5).Visible = False GvGrupos.Columns(5).Visible = False
GvGrupos.Columns(6).Visible = False GvGrupos.Columns(6).Visible = False
GvGrupos.Columns(7).Visible = False GvGrupos.Columns(7).Visible = False
GvGrupos.Columns(8).Visible = False
Else Else
GvGrupos.Columns(4).Visible = True
GvGrupos.Columns(5).Visible = True GvGrupos.Columns(5).Visible = True
GvGrupos.Columns(6).Visible = True GvGrupos.Columns(6).Visible = True
GvGrupos.Columns(7).Visible = True GvGrupos.Columns(7).Visible = True
GvGrupos.Columns(8).Visible = True
End If End If
If DdlGPO.SelectedValue.ToEntero = 2 Then If DdlGPO.SelectedValue.ToEntero = 2 Then
@@ -470,25 +468,8 @@ Partial Class Inventarios_RepAnomalias
GvRow.BackColor = Drawing.ColorTranslator.FromHtml("white") GvRow.BackColor = Drawing.ColorTranslator.FromHtml("white")
Next Next
Dim SbFiltros As New StringBuilder()
SbFiltros.AppendFormat("Almacenes: {0}|", LblAlmacenes.Text)
SbFiltros.AppendFormat("Fecha Inicio: {0} Fecha Fin: {1}|", lbFechaI.Text, lbFechaF.Text)
SbFiltros.AppendFormat("Clasificaciones: {0}|", LblClasif.Text)
SbFiltros.AppendFormat("Clasificaciones Excluidas: {0}|", LblClasificacionesExcluidas.Text)
SbFiltros.AppendFormat("Productos: {0}|", LblProductos.Text)
SbFiltros.AppendFormat("Productos Excluidos: {0}|", LblProductosExcluidos.Text)
SbFiltros.AppendFormat("Proveedores: {0}|", LblProveedores.Text)
SbFiltros.AppendFormat("SubProyecto: {0}|", lbSubProyecto.Text)
SbFiltros.AppendFormat("Estatus: {0}|", lbEstatus.Text)
'GvF.ExportToExcel("Reporte de Inventario Fisico - Productos que Faltan " & Now.ToShortDateString) 'GvF.ExportToExcel("Reporte de Inventario Fisico - Productos que Faltan " & Now.ToShortDateString)
GvTemp.ExportToExcel("Reporte de Inventario Fisico - Productos que Faltan " & Now.ToShortDateString)
ExportarExcelGembox(GvTemp, "Reporte de Inventario Fisico - Productos que Faltan " & Now.ToShortDateString, UsuarioActual, "Reporte de Inventario Fisico - Productos que Faltan", DatosFiltros:=SbFiltros.ToString())
End Sub End Sub
@@ -499,25 +480,8 @@ Partial Class Inventarios_RepAnomalias
GvRow.BackColor = Drawing.ColorTranslator.FromHtml("white") GvRow.BackColor = Drawing.ColorTranslator.FromHtml("white")
Next Next
Dim SbFiltros As New StringBuilder() 'GvS.ExportToExcel("Reporte de Inventario Fisico - Productos que Sobran " & Now.ToShortDateString)
SbFiltros.AppendFormat("Almacenes: {0}|", LblAlmacenes.Text) GvTemp.ExportToExcel("Reporte de Inventario Fisico - Productos que Sobran " & Now.ToShortDateString)
SbFiltros.AppendFormat("Fecha Inicio: {0} Fecha Fin: {1}|", lbFechaI.Text, lbFechaF.Text)
SbFiltros.AppendFormat("Clasificaciones: {0}|", LblClasif.Text)
SbFiltros.AppendFormat("Clasificaciones Excluidas: {0}|", LblClasificacionesExcluidas.Text)
SbFiltros.AppendFormat("Productos: {0}|", LblProductos.Text)
SbFiltros.AppendFormat("Productos Excluidos: {0}|", LblProductosExcluidos.Text)
SbFiltros.AppendFormat("Proveedores: {0}|", LblProveedores.Text)
SbFiltros.AppendFormat("SubProyecto: {0}|", lbSubProyecto.Text)
SbFiltros.AppendFormat("Estatus: {0}|", lbEstatus.Text)
'GvF.ExportToExcel("Reporte de Inventario Fisico - Productos que Faltan " & Now.ToShortDateString)
ExportarExcelGembox(GvTemp, "Reporte de Inventario Fisico - Productos que Sobran " & Now.ToShortDateString, UsuarioActual, "Reporte de Inventario Fisico - Productos que Sobran", DatosFiltros:=SbFiltros.ToString())
End Sub End Sub
@@ -527,48 +491,14 @@ Partial Class Inventarios_RepAnomalias
For Each GvRow As GridViewRow In GvTemp.Rows For Each GvRow As GridViewRow In GvTemp.Rows
GvRow.BackColor = Drawing.ColorTranslator.FromHtml("white") GvRow.BackColor = Drawing.ColorTranslator.FromHtml("white")
Next Next
'GvC.ExportToExcel("Reporte de Inventario Fisico - Productos Coincidentes " & Now.ToShortDateString)
Dim SbFiltros As New StringBuilder() GvTemp.ExportToExcel("Reporte de Inventario Fisico - Productos Coincidentes " & Now.ToShortDateString)
SbFiltros.AppendFormat("Almacenes: {0}|", LblAlmacenes.Text)
SbFiltros.AppendFormat("Fecha Inicio: {0} Fecha Fin: {1}|", lbFechaI.Text, lbFechaF.Text)
SbFiltros.AppendFormat("Clasificaciones: {0}|", LblClasif.Text)
SbFiltros.AppendFormat("Clasificaciones Excluidas: {0}|", LblClasificacionesExcluidas.Text)
SbFiltros.AppendFormat("Productos: {0}|", LblProductos.Text)
SbFiltros.AppendFormat("Productos Excluidos: {0}|", LblProductosExcluidos.Text)
SbFiltros.AppendFormat("Proveedores: {0}|", LblProveedores.Text)
SbFiltros.AppendFormat("SubProyecto: {0}|", lbSubProyecto.Text)
SbFiltros.AppendFormat("Estatus: {0}|", lbEstatus.Text)
ExportarExcelGembox(GvTemp, "Reporte de Inventario Fisico - Productos Coincidentes " & Now.ToShortDateString, UsuarioActual, "Reporte de Inventario Fisico - Productos Coincidentes", DatosFiltros:=SbFiltros.ToString())
End Sub End Sub
Private Sub LnkDescarExcelGrupos_Click(sender As Object, e As EventArgs) Handles LnkDescarExcelGrupos.Click Private Sub LnkDescarExcelGrupos_Click(sender As Object, e As EventArgs) Handles LnkDescarExcelGrupos.Click
'Dim Filtros As String = "Almacenes:aASDSAF|Clasificaciones:sdfasf|Fecha:12/12/2323" Dim Filtros As String = "Almacenes:aASDSAF|Clasificaciones:sdfasf|Fecha:12/12/2323"
'GvGrupos.ExportToExcelGembox("Reporte de Inventario Fisico" & Now.ToShortDateString, UsuarioActual, "Inventario:" & lbTitulo.Text, "", DatosFiltros:=Filtros) GvGrupos.ExportToExcelGembox("Reporte de Inventario Fisico" & Now.ToShortDateString, UsuarioActual, "Inventario:" & lbTitulo.Text, "", DatosFiltros:=Filtros)
Dim SbFiltros As New StringBuilder()
SbFiltros.AppendFormat("Almacenes: {0}|", LblAlmacenes.Text)
SbFiltros.AppendFormat("Fecha Inicio: {0} Fecha Fin: {1}|", lbFechaI.Text, lbFechaF.Text)
SbFiltros.AppendFormat("Clasificaciones: {0}|", LblClasif.Text)
SbFiltros.AppendFormat("Clasificaciones Excluidas: {0}|", LblClasificacionesExcluidas.Text)
SbFiltros.AppendFormat("Productos: {0}|", LblProductos.Text)
SbFiltros.AppendFormat("Productos Excluidos: {0}|", LblProductosExcluidos.Text)
SbFiltros.AppendFormat("Proveedores: {0}|", LblProveedores.Text)
SbFiltros.AppendFormat("SubProyecto: {0}|", lbSubProyecto.Text)
SbFiltros.AppendFormat("Estatus: {0}|", lbEstatus.Text)
ExportarExcelGembox(GvGrupos, "Reporte de Inventario Fisico" & Now.ToShortDateString, UsuarioActual, "Reporte de Inventario Fisico", DatosFiltros:=SbFiltros.ToString())
End Sub End Sub
Public Overrides Sub VerifyRenderingInServerForm(ByVal control As Control) Public Overrides Sub VerifyRenderingInServerForm(ByVal control As Control)
@@ -578,10 +508,10 @@ Partial Class Inventarios_RepAnomalias
Private Sub BanderaSerieLoteCad(Gv As GridView, resultado As DataTable) Private Sub BanderaSerieLoteCad(Gv As GridView, resultado As DataTable)
If resultado IsNot Nothing Then If resultado IsNot Nothing Then
Gv.Columns(6).Visible = resultado.MAX("CveSeccionAlmacen").ToEntero > 0 Gv.Columns(5).Visible = resultado.MAX("CveSeccionAlmacen").ToEntero > 0
Gv.Columns(7).Visible = resultado.MAX("Serie") <> "" Gv.Columns(6).Visible = resultado.MAX("Serie") <> ""
Gv.Columns(8).Visible = resultado.MAX("Lote") <> "" Gv.Columns(7).Visible = resultado.MAX("Lote") <> ""
Gv.Columns(9).Visible = resultado.MAX("FechaCaducidad").ToDate > MinFecha Gv.Columns(8).Visible = resultado.MAX("FechaCaducidad").ToDate > MinFecha
End If End If
End Sub End Sub
@@ -781,161 +711,4 @@ Partial Class Inventarios_RepAnomalias
End Sub End Sub
Public Sub ExportarExcelGembox(GridView As GridView, NombreArchivoXLSx As String, Usuario As Usuario, Titulo As String, Optional DatoTituloExtra As String = "", Optional DatosFiltros As String = "", Optional AnchoImagen As Integer = 100, Optional AlturaImagen As Integer = 100)
Dim sw1 As New StringWriter()
Dim htw1 As New HtmlTextWriter(sw1)
GridView.RenderControl(htw1)
Dim options = GemBox.Spreadsheet.LoadOptions.HtmlDefault
Dim htmlStream1 = New MemoryStream(options.Encoding.GetBytes(sw1.ToString()))
htmlStream1.Position = 0
Dim sr1 As New StreamReader(htmlStream1)
Dim myStr1 = sr1.ReadToEnd()
sr1.Dispose()
htmlStream1.Dispose()
sw1.Dispose()
Dim HtmlCompleto As String = myStr1
HtmlCompleto = Regex.Replace(HtmlCompleto, "\<[\/]*a[^\>]*\>", "")
Dim htmlStream5 = New MemoryStream(options.Encoding.GetBytes(HtmlCompleto))
GemBox.Spreadsheet.SpreadsheetInfo.SetLicense(SerialGemBoxSpreadsheet)
Dim excel As GemBox.Spreadsheet.ExcelFile
excel = GemBox.Spreadsheet.ExcelFile.Load(htmlStream5, options)
If Usuario IsNot Nothing Then
Dim TotalRowHeader As Integer = 6
Dim TotalRowFooter As Integer = 2
Dim worksheet = excel.Worksheets(0)
worksheet.Rows.InsertEmpty(0, TotalRowHeader)
Dim celdasConTexto = worksheet.GetUsedCellRange(True)
celdasConTexto.Style.Font.Name = "Calibri Light"
Dim RangoNombreEmpresa = worksheet.Cells.GetSubrangeAbsolute(1, celdasConTexto.FirstColumnIndex, 1, celdasConTexto.LastColumnIndex)
RangoNombreEmpresa.Merged = True
RangoNombreEmpresa.Value = Usuario.Empresa.Empresa
RangoNombreEmpresa.Style.Font.Size = 18 * 20
RangoNombreEmpresa.Style.Font.Name = "Calibri Light"
RangoNombreEmpresa.Style.HorizontalAlignment = GemBox.Spreadsheet.HorizontalAlignmentStyle.Center
RangoNombreEmpresa.Style.VerticalAlignment = GemBox.Spreadsheet.VerticalAlignmentStyle.Center
Dim RangoTitulo = worksheet.Cells.GetSubrangeAbsolute(3, celdasConTexto.FirstColumnIndex, 3, celdasConTexto.LastColumnIndex)
RangoTitulo.Merged = True
RangoTitulo.Value = Titulo
RangoTitulo.Style.Font.Size = 20 * 20
RangoTitulo.Style.Font.Name = "Calibri Light"
RangoTitulo.Style.HorizontalAlignment = GemBox.Spreadsheet.HorizontalAlignmentStyle.Center
RangoTitulo.Style.VerticalAlignment = GemBox.Spreadsheet.VerticalAlignmentStyle.Center
If DatoTituloExtra.Length > 0 Then
Dim RangoDatoTituloExtra = worksheet.Cells.GetSubrangeAbsolute(TotalRowHeader, celdasConTexto.FirstColumnIndex, TotalRowHeader, celdasConTexto.LastColumnIndex)
RangoDatoTituloExtra.Merged = True
RangoDatoTituloExtra.Value = DatoTituloExtra
RangoDatoTituloExtra.Style.Font.Size = 20 * 20
RangoDatoTituloExtra.Style.Font.Name = "Calibri Light"
RangoDatoTituloExtra.Style.HorizontalAlignment = GemBox.Spreadsheet.HorizontalAlignmentStyle.Left
RangoDatoTituloExtra.Style.VerticalAlignment = GemBox.Spreadsheet.VerticalAlignmentStyle.Center
End If
If DatosFiltros.Length > 0 Then
Dim Arreglo As String() = DatosFiltros.Split("|"c)
worksheet.Rows.InsertEmpty(TotalRowHeader, Arreglo.Count)
For Each TextoFiltro As String In Arreglo
Dim RangoDatosFiltro = worksheet.Cells.GetSubrangeAbsolute(TotalRowHeader, celdasConTexto.FirstColumnIndex, TotalRowHeader, celdasConTexto.LastColumnIndex)
RangoDatosFiltro.Merged = True
RangoDatosFiltro.Style.WrapText = True
RangoDatosFiltro.Value = TextoFiltro
RangoDatosFiltro.Style.Font.Size = 12 * 20
RangoDatosFiltro.Style.Font.Name = "Calibri Light"
RangoDatosFiltro.Style.HorizontalAlignment = GemBox.Spreadsheet.HorizontalAlignmentStyle.Left
RangoDatosFiltro.Style.VerticalAlignment = GemBox.Spreadsheet.VerticalAlignmentStyle.Center
TotalRowHeader += 1
Next
End If
'TotalRowHeader += 2
For i = celdasConTexto.FirstColumnIndex To celdasConTexto.LastColumnIndex
worksheet.Rows(TotalRowHeader).Cells(i).Style.Font.Size = 12 * 20
worksheet.Rows(TotalRowHeader).Cells(i).Style.HorizontalAlignment = GemBox.Spreadsheet.HorizontalAlignmentStyle.Center
worksheet.Rows(TotalRowHeader).Cells(i).Style.VerticalAlignment = GemBox.Spreadsheet.VerticalAlignmentStyle.Center
worksheet.Rows(TotalRowHeader).Cells(i).Style.FillPattern.SetPattern(GemBox.Spreadsheet.FillPatternStyle.Solid, GemBox.Spreadsheet.SpreadsheetColor.FromArgb(75, 119, 190), GemBox.Spreadsheet.SpreadsheetColor.FromArgb(255, 255, 255))
worksheet.Rows(TotalRowHeader).Cells(i).Style.Font.Color = GemBox.Spreadsheet.SpreadsheetColor.FromArgb(255, 255, 255)
If i > 0 Then
Try
worksheet.Columns(i).AutoFit(1)
Catch ex As Exception
End Try
End If
Next
Dim IndexEndTable As Integer = GridView.Rows.Count + TotalRowHeader + TotalRowFooter
worksheet.Rows(IndexEndTable).Cells(0).Value = "Usuario Imprimió"
worksheet.Rows(IndexEndTable + 1).Cells(0).Value = Usuario.Nombre
worksheet.Rows(IndexEndTable).Cells(2).Value = "Fecha Impresión"
worksheet.Rows(IndexEndTable + 1).Cells(2).Value = DateTime.Now.ToString("dd/MM/yyyy")
Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", Usuario.Empresa.Ruta))
If Imagen.Exists Then
Dim Ruta As String = String.Format("{0}/Logo.png", Usuario.Empresa.Ruta)
Using sr As New StreamReader(Ruta)
Dim ms As New MemoryStream()
sr.BaseStream.CopyTo(ms)
worksheet.Pictures.Add(ms, ExcelPictureFormat.Png, "A1", AnchoImagen, AlturaImagen, LengthUnit.Pixel)
End Using
End If
For I = celdasConTexto.FirstColumnIndex To celdasConTexto.LastColumnIndex
If I > 0 Then
'If 1 = 1 Then
' worksheet.Columns(I + 1).Style.NumberFormat = "#,##0.00"
'Else
' worksheet.Columns(I + 1).Style.NumberFormat = "#,##"
'End If
worksheet.Columns(I + 1).Style.NumberFormat = "@"
Try
worksheet.Columns(I).AutoFit(1)
Catch ex As Exception
End Try
End If
Next
End If
excel.Save(HttpContext.Current.Response, $"{NombreArchivoXLSx}.xlsx")
End Sub
End Class End Class