elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Trabajando con las ramas de git (tercera parte)


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP)
| | | |-+  Programación Visual Basic (Moderadores: LeandroA, seba123neo)
| | | | |-+  Listview A Excel (Aliner celda)
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Listview A Excel (Aliner celda)  (Leído 9,361 veces)
TheGhost(Z)

Desconectado Desconectado

Mensajes: 230



Ver Perfil
Listview A Excel (Aliner celda)
« en: 13 Julio 2007, 23:30 pm »

Holas, veran estoy exportando el contenido de un Listview a EXcel. Tengo un ''
problema al Aliner las celdasIzqueirda, centrarm, derecha
gracias por la yuda desde ya..

Código:
Private Sub ExportarListadoMSExcel()
Dim AppExcel As Object    
Set AppExcel = CreateObject("Excel.application")
With AppExcel
    .Visible = True
    .Workbooks.Add '' Agregamos un Libro Nuevo

    Dim nFila As Integer
    nFila = 1 '' Agregos los titulos a nuestra columnas
    .Cells(nFila, 1) = "Id"
    .Cells(nFila, 2) = "Pais"
    .Cells(nFila, 3) = "Estado"
    Dim i As Long
    For i = 1 To Me.ListView1.ListItems.Count
        nFila = nFila + 1
        .Cells(nFila, 1) = Me.ListView1.ListItems(i).Text
        .Cells(nFila, 2) = Me.ListView1.ListItems(i).ListSubItems(1).Text
        .Cells(nFila, 3) = Me.ListView1.ListItems(i).ListSubItems(2).Text
    Next i
    
    .range("A1:C1").Font.Bold = True
    .range("A1:C1").Interior.Color = RGB(192, 200, 200)
    .Cells.EntireColumn.AutoFit

    '' ************* ERROR AL ALINEAR ayuda porfa.. **********************
    .Range("C1").TextAlign = fmTextAlignCenter
    .Range("A1:H1").HorizontalAlignment = xlCenter
    .cell(1,).TextAlign = fmTextAlignCenter
    '' ************************************************

    .ActiveWorkbook.SaveAs App.Path & "listado.xls" ''Guardas la hoja actual

End With

End Sub


En línea

Sancho.Mazorka


Desconectado Desconectado

Mensajes: 480


Gamer & Programador


Ver Perfil WWW
Re: Listview A Excel (Aliner celda)
« Respuesta #1 en: 15 Julio 2007, 05:15 am »

Sino me equivoco estas haciendo una aplicacion para exportar a diferentes aplicaciones una base de datos o unos datos ingresados en una FlexiGrid, yo te ayude en la de SQL pero de Excel ni idea todavia, perdon!


Sancho.Mazorka    :¬¬


En línea

Ganador Xeon Web Server ! ! !    Sancho.Mazorka :D
http://foro.elhacker.net/index.php/topic,171903.75.html


TheGhost(Z)

Desconectado Desconectado

Mensajes: 230



Ver Perfil
Re: Listview A Excel (Aliner celda)
« Respuesta #2 en: 19 Julio 2007, 04:45 am »

Hola si alguien sabe alinear una celda de excel desde vb.

Me han pasado un codigo:
Código:
.Range("B4:L4").HorizontalAlignment = True

Pero no alinea nada..
En línea

Sancho.Mazorka


Desconectado Desconectado

Mensajes: 480


Gamer & Programador


Ver Perfil WWW
Re: Listview A Excel (Aliner celda)
« Respuesta #3 en: 19 Julio 2007, 23:34 pm »

Tu aqui tienes error en la linea que te voy a marcar, ya que si no existe un funcion te pide 1 parametro no puede colocarle 2, o colocar una "," sin poner el 2 parametro porque da error:

Código
  1. Private Sub ExportarListadoMSExcel()
  2. Dim AppExcel As Object    
  3. Set AppExcel = CreateObject("Excel.application")
  4. With AppExcel
  5.    .Visible = True
  6.    .Workbooks.Add '' Agregamos un Libro Nuevo
  7.  
  8.    Dim nFila As Integer
  9.    nFila = 1 '' Agregos los titulos a nuestra columnas
  10.    .Cells(nFila, 1) = "Id"
  11.    .Cells(nFila, 2) = "Pais"
  12.    .Cells(nFila, 3) = "Estado"
  13.    Dim i As Long
  14.    For i = 1 To Me.ListView1.ListItems.Count
  15.        nFila = nFila + 1
  16.        .Cells(nFila, 1) = Me.ListView1.ListItems(i).Text
  17.        .Cells(nFila, 2) = Me.ListView1.ListItems(i).ListSubItems(1).Text
  18.        .Cells(nFila, 3) = Me.ListView1.ListItems(i).ListSubItems(2).Text
  19.    Next i
  20.  
  21.    .range("A1:C1").Font.Bold = True
  22.    .range("A1:C1").Interior.Color = RGB(192, 200, 200)
  23.    .Cells.EntireColumn.AutoFit
  24.  
  25.    '' ************* ERROR AL ALINEAR ayuda porfa.. **********************
  26.    .Range("C1").TextAlign = fmTextAlignCenter
  27.    .Range("A1:H1").HorizontalAlignment = xlCenter
  28.    .cell(1,).TextAlign = fmTextAlignCenter 'ERORRRRRR  .cell(1,)  sacale la "," (coma)
  29.    '' ************************************************
  30.  
  31.    .ActiveWorkbook.SaveAs App.Path & "listado.xls" ''Guardas la hoja actual
  32.  
  33. End With
  34.  
  35. End Sub

y otra cosa, podes postear tu code, o pasarmelo, me interesa ayudarte y de paso me sirve a mi. rhcp_269@hotmail.com
Sancho.Mazorka    :¬¬
En línea

Ganador Xeon Web Server ! ! !    Sancho.Mazorka :D
http://foro.elhacker.net/index.php/topic,171903.75.html


TheGhost(Z)

Desconectado Desconectado

Mensajes: 230



Ver Perfil
Re: Listview A Excel (Aliner celda)
« Respuesta #4 en: 31 Julio 2007, 20:59 pm »

Despues de buscar y buscar consegui esto.. Si quieren mas codecs lo sacan de las Macros que se hacen en MS Excel. Espero les sirva.


Código:
Private Sub Form_Load()
Dim AppExcel As Excel.Application
Set AppExcel = CreateObject("Excel.Application")

With AppExcel
    .Workbooks.Add
   
    'Formatos
    With .Range("A1")
        .Font.Size = 18
        .Value = "NUCLEAR SILO READY!"
        .Font.Bold = True
        .Font.Name = "Arial Narrow" ' , etc, etc
    End With
   
  ' alinear celda
    With .Range("C11")
        .HorizontalAlignment = xlLeft
        .VerticalAlignment = xlTop

         'Reducir hasta ajustar
        .ReadingOrder = xlContext
        .WrapText = True
    End With

   'Combinar celdas
  .Range("D14:E15").Merge


    'Auto ajustar
    .Range("B:B").EntireColumn.AutoFit
    ' Ancho de columnas
    .Range("C:C").ColumnWidth = 26.71
    .Range("D:D").ColumnWidth = 28.57
    .Range("E:E").ColumnWidth = 10.29
   
    'margenes de la hora de imprecion
    .Sheets("Hoja1").PageSetup.LeftMargin = Application.InchesToPoints(0.13)
    .Sheets("Hoja1").PageSetup.RightMargin = Application.InchesToPoints(0.13)
    .Sheets("Hoja1").PageSetup.TopMargin = Application.InchesToPoints(0.13)
    .Sheets("Hoja1").PageSetup.BottomMargin = Application.InchesToPoints(0.13)

    'Bordes
    .Range("D14:G15").Borders(xlEdgeTop).LineStyle = xlContinuous
    .Range("D14:G15").Borders(xlEdgeTop).Weight = xlThin
   
    .Range("D14:G15").Borders(xlEdgeBottom).LineStyle = xlContinuous
    .Range("D14:G15").Borders(xlEdgeBottom).Weight = xlThin
   
    .Range("D14:G15").Borders(xlEdgeLeft).LineStyle = xlContinuous
    .Range("D14:G15").Borders(xlEdgeLeft).Weight = xlThin
   
    .Range("D14:G15").Borders(xlEdgeRight).LineStyle = xlContinuous
    .Range("D14:G15").Borders(xlEdgeRight).Weight = xlThin
   
    'Proteger hoja (sin contraseña)
    .Sheets("Hoja1").Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
   
    'Cambiar de nombre a la hoja
    .Sheets("Hoja1").Name = Format(2007, "0000000000")
   
    'Mostrar libro
    .Visible = True
   
    'Guardar libro
    .ActiveWorkbook.SaveAs App.Path & "LOL.xls"
    ' imprimir libro
    .Sheets("Hoja1").PrintOut Copies:=1, Collate:=True
    'cerrar
    .Quit
    Set AppExcel = Nothing
End With
End Sub
En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
programcion en excel. modificar valor en la misma celda
Dudas Generales
josco 0 2,566 Último mensaje 11 Junio 2012, 07:30 am
por josco
Como escribir en una celda de Excel desde otra celda
Software
javier234- 4 2,921 Último mensaje 22 Junio 2012, 21:57 pm
por maxtextla
Buscar palabra en celda Excel
Programación General
Lain0x 2 2,803 Último mensaje 2 Diciembre 2013, 07:36 am
por Lain0x
Fijar relleno de una celda de excel
Software
Luish@o 0 1,082 Último mensaje 22 Abril 2015, 22:51 pm
por Luish@o
Listview A Excel (copiar a un rango de celda)
.NET (C#, VB.NET, ASP)
Ericks 0 2,729 Último mensaje 15 Septiembre 2017, 23:02 pm
por Ericks
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines