I show u a example .

Imports excel = Microsoft.Office.Interop.Excel

Sub rptoGuia(ByVal dgv As DataGridView)
        Dim oexcel As excel.Application
        Dim objLibroExcel As excel.Workbook
        Dim objHojaExcel As excel.Worksheet
        oexcel = New excel.Application
        Dim file As String = Config.Ruta_Excel + "\rptguia.xlsx"
        Try
            If IO.File.Exists(file) Then
                objLibroExcel = oexcel.Workbooks.Open(file) ' ABRIR XLSX
                objHojaExcel = objLibroExcel.Worksheets(1)
                objHojaExcel.Visible =
excel.XlSheetVisibility.xlSheetVisible
                objHojaExcel.Activate()
                Dim nanulados As Integer = 0
                Dim i As Integer = 5
                With objHojaExcel
                    .Cells(1, 1) = "S&L MODA S.A.C."
                    .Cells(3, 3) = "RELACION GENERAL DE GUIAS DE REMISION"
                    For Each dr As DataGridViewRow In dgv.Rows
                        i += 1
                        ' VALIDACION DE ANULADOS
                        If dr.Cells("anulado").Value = "1" Then
                            Dim x As Integer = 0
                            Do While x < 7
                                x += 1
                                .Cells(i, x).Interior.ColorIndex = 15
                            Loop
                            nanulados += 1
                        End If
                        ' IMPRIMIR ITEMS.
                        .Cells(i, 1) = Format(dr.Cells("fch_ingre").Value,
"dd/MM/yyyy").ToString
                        .Cells(i, 2) = dr.Cells("n_doc").Value
                        .Cells(i, 3) = dr.Cells("nom_cli").Value
                        .Cells(i, 4) = dr.Cells("procedencia").Value
                        .Cells(i, 5) = dr.Cells("destino").Value
                        .Cells(i, 6) = dr.Cells("nom_trans").Value
                        .Cells(i, 7) = dr.Cells("tipo_translado").Value
                    Next
                    'RESUMEN DEL REPORTE
                    i += 2
                    .Cells(i, 6).HorizontalAlignment =
excel.XlHAlign.xlHAlignLeft ' TABULACION
                    .Cells(i, 6).interior.color = RGB(31, 73, 125) ' COLOR
DE FONDO
                    .Cells(i, 6).FONT.color = RGB(255, 255, 255) ' COLOR DE
FUENTE
                    .Rows(i).Font.Bold = True
                    .Cells(i, 6) = "Total Guias: "
                    .Cells(i, 7) = dgv.Rows.Count
                    i += 1
                    .Cells(i, 6).HorizontalAlignment =
excel.XlHAlign.xlHAlignLeft
                    .Cells(i, 6).interior.color = RGB(31, 73, 125)
                    .Cells(i, 6).FONT.color = RGB(255, 255, 255)
                    .Rows(i).Font.Bold = True
                    .Cells(i, 6) = "Anulados: "
                    .Cells(i, 7) = Str(nanulados) + " Guias"
                End With
                If MessageBox.Show("Reporte Generado Exitosamente",
"Aviso", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) =
Windows.Forms.DialogResult.OK Then
                    oexcel.Visible = True
                    oexcel = Nothing
                End If
            Else
                MessageBox.Show("Plantilla No Existe..", "ERROR",
MessageBoxButtons.OK, MessageBoxIcon.Error)
            End If
        Catch ex As Exception
        End Try
    End Sub




2012/6/1 Suraj <suraj....@gmail.com>

>
> Dear friends,
>
> I need to insert data into particular cells of excel sheet like starting
> from B6.
>
> I have the data that need to be inserted in a dataset. How can I insert
> data into the excel sheet from the dataset.
>
> I am using Oledb connection.
>
> Regards,
>
> Vikas
>
>  --
> You received this message because you are subscribed to the Google
> Groups "DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML
> Web Services,.NET Remoting" group.
> To post to this group, send email to dotnetdevelopment@googlegroups.com
> To unsubscribe from this group, send email to
> dotnetdevelopment+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/dotnetdevelopment?hl=en?hl=en
> or visit the group website at http://megasolutions.net
>



-- 
Manuel Lazo.

-- 
You received this message because you are subscribed to the Google
Groups "DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML
Web Services,.NET Remoting" group.
To post to this group, send email to dotnetdevelopment@googlegroups.com
To unsubscribe from this group, send email to
dotnetdevelopment+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/dotnetdevelopment?hl=en?hl=en
or visit the group website at http://megasolutions.net

Reply via email to