Como puedo hacer un contador en OpenOffice Calc?

Para discutir temas generales, incluso si no tienen que ver directamente con Apache OpenOffice
Responder
Johan Manuel Ramos
Mensajes: 6
Registrado: Mié Jul 29, 2015 8:51 pm

Como puedo hacer un contador en OpenOffice Calc?

Mensaje por Johan Manuel Ramos »

Tengo un archivo en Open Office Calc con casos de prueba, pero quiero hacer un contador en los macros, pero no se como?
Podria alguien ayudarme para hacer el contador?
basicamente el contador tiene que contar cuantos registros tengo.
y en el codigo tengo esto:

Código: Seleccionar todo

Sub Main

 Dim oSheet : oSheet = ThisComponent.Sheets.getByName("TestCases") 
    Dim fs, f, i
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set f = fs.CreateTextFile("C:\Temp\testfile.xml", True)
    
      
    f.WriteLine ("<sections>")
    f.WriteLine ("<sectiones>")
        
     
    for i = 2 To 10
 
     oCell = oSheet.getCellByPosition(1,i)
    f.WriteLine ("<case>" & oCell.getString & "")
     
     oCell = oSheet.getCellByPosition(2,i)
    f.WriteLine ("<Id>" & oCell.getString & "</Id>") 
          
      oCell = oSheet.getCellByPosition(3,i)
    f.WriteLine ("<Title>" & oCell.getString & "</Title>")     
              
       
     oCell = oSheet.getCellByPosition(4,i)
    f.WriteLine ("<Type>" & oCell.getString & "</Type>")
    
     oCell = oSheet.getCellByPosition(5,i)
    f.WriteLine ("<Priority>" & oCell.getString & "</Priority>")
    
     oCell = oSheet.getCellByPosition(6,i)
    f.WriteLine ("<Estimate>" & oCell.getString & "</Estimate>")
    
     oCell = oSheet.getCellByPosition(7,i)
    f.WriteLine ("<Milestone>" & oCell.getString & "</Milestone>")
    
     oCell = oSheet.getCellByPosition(8,i)
    f.WriteLine ("<References>" & oCell.getString & "</References>")
    
     oCell = oSheet.getCellByPosition(9,i)
    f.WriteLine ("" & oCell.getString & "</case>")
    
      Next i
    
    f.Close


End Sub
Que me hace falta para hacer que me cuente cuantos registros tengo?
Última edición por xiseme el Jue Jul 30, 2015 6:37 am, editado 2 veces en total.
Razón: Etiquetas Code
OpenOffice Basic Calc 4.1.1
Windows 7 Professional
Service Pack 1
Avatar de Usuario
SLV-es
Mensajes: 4894
Registrado: Jue Ago 26, 2010 1:25 am
Ubicación: España
Contactar:

Re: Como puedo hacer un contador en OpenOffice Calc?

Mensaje por SLV-es »

Supongo que en realidad lo que buscas es saber cuantas filas tienes en la hoja, para poder exportarlas al documento xml ¿es así?
ultima-fila-utilizada.ods
(11.4 KiB) Descargado 228 veces
Aunque yo pondría un bucle do while true que empiece leyendo la primera fila y que vaya incrementando el contador de fila, y saldría del bucle cuando encuentre la primera celda vacía.

Código: Seleccionar todo

i=2
do while true

     oCell = oSheet.getCellByPosition(1,i)

    if oCell.getString = "" then exit do

    f.WriteLine ("<case>" & oCell.getString & "")
     
    ...

    i=i+1   

loop
+info en la web "no oficial" dedicada a OpenOffice en Español
AOO 4.1.2 y LibO 4.4.6 en W10 y en Lliurex
No respondo mensajes privados sobre AOO, por favor, utiliza el foro para tus preguntas
Responder