RESPONDER UNA PREGUNTA

Si para responder la pregunta, crees necesario enviar un archivo adjunto, puedes hacerlo a traves del correo [email protected]

    Pregunta:  61877 - TRASLADO DE REPORTE A EXCEL 2003
Autor:  marcela perez
hola a todos necesito ayuda con esto soy nueva en reportes y necesitio trasladar un reporte por medio de un boton el reporte tiene sub totales logro parsarlo a excel pero sin esos sub totales

boton:
Private Sub BtnTrasladoExcel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnTrasladoExcel.Click

'' excel 2003
Dim oExcel As Excel.ApplicationClass
Dim oBooks As Excel.Workbooks
Dim oBook As Excel.WorkbookClass
Dim oSheet As Excel.Worksheet

'' Inicia Excel y abre el workbook
oExcel = CreateObject("Excel.Application")
oExcel.Visible = True
oBooks = oExcel.Workbooks
oBook = oExcel.Workbooks.Add
oSheet = oBook.Sheets(1)

Const ROW_FIRST = 2
Dim iRow As Int64 = 1

'' Encabezado
oSheet.Cells(ROW_FIRST, 1) = "CODIGO"
oSheet.Cells(ROW_FIRST, 2) = "CUENTA"
oSheet.Cells(ROW_FIRST, 3) = "ENERO"
oSheet.Cells(ROW_FIRST, 4) = "FEBRERO"
oSheet.Cells(ROW_FIRST, 5) = "MARZO"
oSheet.Cells(ROW_FIRST, 6) = "ABRIL"
oSheet.Cells(ROW_FIRST, 7) = "MAYO"
oSheet.Cells(ROW_FIRST, 8) = "JUNIO"
oSheet.Cells(ROW_FIRST, 9) = "ACUMULADO"

oSheet.Columns(1).ColumnWidth = 10
oSheet.Columns(2).ColumnWidth = 40
oSheet.Columns(3).ColumnWidth = 15
oSheet.Columns(4).ColumnWidth = 15
oSheet.Columns(5).ColumnWidth = 15
oSheet.Columns(6).ColumnWidth = 15
oSheet.Columns(7).ColumnWidth = 15
oSheet.Columns(8).ColumnWidth = 15
oSheet.Columns(9).ColumnWidth = 15

'' Loop que almacena los datos
Dim rowCustomer As DSReportesFinancieros.ReportesFinancierosResultadosMensualAnualRow
For Each rowCustomer In Me.DsReportesFinancieros1.ReportesFinancierosResultadosMensualAnual
Dim iCurrRow As Int64 = ROW_FIRST + iRow + 1

oSheet.Cells(iCurrRow, 1) = rowCustomer.codigo_cuenta_contable
oSheet.Cells(iCurrRow, 2) = rowCustomer.nombre_cuenta_contable
' oSheet.Cells(iCurrRow, 3) = rowCustomer.mes01
If rowCustomer.IsNull("mes01") = True Then
oSheet.Cells(iCurrRow, 3) = ""
Else
oSheet.Cells(iCurrRow, 3) = rowCustomer.mes01
End If
If rowCustomer.IsNull("mes02") = True Then
oSheet.Cells(iCurrRow, 4) = ""
Else
oSheet.Cells(iCurrRow, 4) = rowCustomer.mes02
End If
If rowCustomer.IsNull("mes03") = True Then
oSheet.Cells(iCurrRow, 5) = ""
Else
oSheet.Cells(iCurrRow, 5) = rowCustomer.mes03
End If
If rowCustomer.IsNull("mes04") = True Then
oSheet.Cells(iCurrRow, 6) = ""
Else
oSheet.Cells(iCurrRow, 6) = rowCustomer.mes04
End If
If rowCustomer.IsNull("mes05") = True Then
oSheet.Cells(iCurrRow, 7) = ""
Else
oSheet.Cells(iCurrRow, 7) = rowCustomer.mes05
End If
If rowCustomer.IsNull("mes06") = True Then
oSheet.Cells(iCurrRow, 8) = ""
Else
oSheet.Cells(iCurrRow, 8) = rowCustomer.mes06
End If
If rowCustomer.IsNull("acumulado") = True Then
oSheet.Cells(iCurrRow, 9) = ""
Else
oSheet.Cells(iCurrRow, 9) = rowCustomer.acumulado
End If

iRow += 1
Next

'' Fórmula
oSheet.Cells(ROW_FIRST + iRow + 1, 3) = "=SUMA(C" & (ROW_FIRST + 1) & ".." & "C" & (ROW_FIRST + iRow - 1) & ")"

''Guardar
oExcel.Application.ActiveWorkbook.SaveAs("E:reporte.xls")
MessageBox.Show("Finalizado", " Verificación ", MessageBoxButtons.OK, MessageBoxIcon.Information)


Nombre
Apellidos
Correo
Comentarios