hacker


Ingresar con nombre de usuario, contraseña y duración de la sesión
| Portal Hacker | Editorial | Descargas | Ezine |
Inicio Ayuda Ingresar Registrarse
13 de Octubre de 2008, 07:19:53
Noticias: Convocatoria E-zine CPH #2
Para ver este enlace Registrate o Inicia Sesion
> Aquí

+  Foros pOrtal Hacker
|-+  Programacion
| |-+  Programación en general
| | |-+  Visual Basic (Moderadores: ranefi, crypto136, ziBboh, >> s E t H <<)
| | | |-+  Como imprimir un Datagrid
0 Usuarios y 1 Visitante están viendo este tema. « anterior próximo »
Páginas: [1] Ir Abajo Imprimir
Autor Tema: Como imprimir un Datagrid  (Leído 530 veces)
FoMoIrEoMX
NZ1
*
Desconectado Desconectado

Mensajes: 53


EL AZAR FAVORECE A UNA MENTE PREPARADA


Ver Perfil
« : 07 de Agosto de 2006, 01:53:28 »

Si alguien me pudiera decir como le puedo hacer para imprimir el contenido de un datagrid, por su atencion gracias

 Grin

En línea
ranefi
Moderador Global
*****
Desconectado Desconectado

Mensajes: 1,191


SELECT * FROM guapos WHERE papito_chulo = 'ranefi'


Ver Perfil WWW
« Respuesta #1 : 08 de Agosto de 2006, 06:34:28 »

Hola, esta es una de muchas formas que existen.

Código no funcional por sí sólo

Código:

Private Sub Command1_Click()
'+++++++++++++++++++++++++++++++++++++++++++
' Reference : MicroSoft Excel 9.0 Object Library
'+++++++++++++++++++++++++++++++++++++++++++
Dim xl As Excel.Application
Dim wb As Object
Dim ws As Object
Dim excelwasnotrunnung As Boolean

' Make New Object
Set xl = CreateObject("Excel.Application")

' Display Screen
xl.Application.Visible = True
' Add Excel
xl.Workbooks.Add
xl.Worksheets("HOJA1").Name = "HelloSheet" ' Change Name of Sheet

Dim i, j, k, p As Integer

k = Data1.Recordset.RecordCount - 1 ' Count Total Row in DB

p = Data1.Recordset.Fields.Count - 1   ' cOUNT Total Column in DB

With DBGrid1
 

  For i = 0 To k   ' Starting from [0] because the start point of  DBGRID
                       '  is [0]  <---- STARTING ROW
                       
     For j = 0 To p     ' Starting from [0] because the start point of  DBGRID
                       '  is [0]  <--- STARTING COLUMN
                     
           
          .Row = i
          .Col = j
         
                           
                           
         '------------------------------------------------------------
         '  IF Some of Data on your DB may have NULL. DO NOT worry !
         '  The relevant point of cells in the Excel will not be
         '  shown  [without error]
         '
         '  If you want to test !
         '  1). Open DB1.mdb File
         '  2). Delete any of data in the Field
         '  3). Save
         '  4). Run Program
         '------------------------------------------------------------
                           
        xl.Worksheets("HelloSheet").Cells(i + 1, j + 1).Value = .Text
                                                                         
                                                                         
          '----------------------- (i + 1, j + 1) --------------------
          ' This is very very important matter !
          ' If you not start + 1 . Then, You will see critical error
          ' during transfer data form DBGRID to Excel
          ' because The starting point of the Excel's cells is [Cells(1, 1)]
          ' NOT (0, 0) !
          '
          ' In addition, If you want to shift the starting point of output
          ' on the Excel, Then you can change like ..
          '
          ' .Cells(i + 5, j + 5).Value = .Text  ... Whatever you want !
          '------------------------------------------------------------------
                                                                         
      Next
     
         
  Next

End With
'---------------CÓDIGO AGREGADO POR EL COCHINÓN DE ranefi----------------------
    xl.Worksheets.PrintOut Copies:=1 '<----ESTA ES LA PARTE DE CÓDIGO QUE AGREGUÉ
'------------------------------------------------------------------------------

    Set wb = Nothing
    Set xl = Nothing


End Sub


Deberás agregar esta referencia: MicroSoft Excel 9.0 Object Library y obviamente tener una conexión ya establecida. Nos vemos.
En línea


SELECT * FROM mejores_batos_ del_mundo WHERE id = (SELECT DISTINCT id_guapo FROM los_mas_guapos _del_mundo WHERE papito_chulo = 'ranefi')
Páginas: [1] Ir Arriba Imprimir 
« anterior próximo »
Ir a:  


Ingresar con nombre de usuario, contraseña y duración de la sesión

Powered by SMF 1.1.6 | SMF © 2006-2008, Simple Machines LLC hacker

Juegos gratis - Articulos PHP - Juegos - Trucos - Letras - Juegos - Juegos Online