Java - Como llamar un metodo entro de otro

 
Vista:

Como llamar un metodo entro de otro

Publicado por Sebastián M. Barrionuevo (21 intervenciones) el 11/11/2009 02:37:49
Hola soy novato en java y necesitaria saber como hago para llamar un metodo dentro de otro. Los 2 metodos estan dentro de la misma clase, Tengo un metodo llamado conexionXLS y otro que se llama leerXLS. Primero necesito conectarme a conexionXLS y después a leerXLS, pero me da error. Acá dejo el codigo.

package conexionDAO;

import java.io.File;
import java.io.IOException;

import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;

public class Consulta {

public void conexionXLS() throws IOException, BiffException{
Workbook archivo = Workbook.getWorkbook(new File("f:\\llamadas_mda_Octubre.xls"));
}

public void leerXLS() throws IOException, BiffException {


Sheet fila = archivo.getSheet(0); //esto hace referencia al metodo de arriba

Cell a0 = fila.getCell(0, 0);
Cell a1 = fila.getCell(1, 0);
Cell a2 = fila.getCell(2, 0);
Cell a3 = fila.getCell(3, 0);
Cell a4 = fila.getCell(4, 0);
Cell a5 = fila.getCell(5, 0);
Cell a6 = fila.getCell(6, 0);
Cell a7 = fila.getCell(7, 0);
Cell a8 = fila.getCell(8, 0);
Cell a9 = fila.getCell(9, 0);
Cell a10 = fila.getCell(10, 0);
Cell a11 = fila.getCell(11, 0);
Cell a12 = fila.getCell(12, 0);
Cell a13 = fila.getCell(13, 0);
Cell a14 = fila.getCell(14, 0);
Cell a15 = fila.getCell(15, 0);

String titulo0 = a0.getContents();
String titulo1 = a1.getContents();
String titulo2 = a2.getContents();
String titulo3 = a3.getContents();
String titulo4 = a4.getContents();
String titulo5 = a5.getContents();
String titulo6 = a6.getContents();
String titulo7 = a7.getContents();
String titulo8 = a8.getContents();
String titulo9 = a9.getContents();
String titulo10 = a10.getContents();
String titulo11 = a11.getContents();
String titulo12 = a12.getContents();
String titulo13 = a13.getContents();
String titulo14 = a14.getContents();
String titulo15 = a15.getContents();

String[][] arreglo = new String[96][15];

for (int xcol = 1; xcol <= 33; xcol++) {
if ((fila.getCell(0, xcol)) != null) {
Cell b0 = fila.getCell(0, xcol);
Cell b1 = fila.getCell(1, xcol);
Cell b2 = fila.getCell(2, xcol);
Cell b3 = fila.getCell(3, xcol);
Cell b4 = fila.getCell(4, xcol);
Cell b5 = fila.getCell(5, xcol);
Cell b6 = fila.getCell(6, xcol);
Cell b7 = fila.getCell(7, xcol);
Cell b8 = fila.getCell(8, xcol);
Cell b9 = fila.getCell(9, xcol);
Cell b10 = fila.getCell(10, xcol);
Cell b11 = fila.getCell(11, xcol);
Cell b12 = fila.getCell(12, xcol);
Cell b13 = fila.getCell(13, xcol);
Cell b14 = fila.getCell(14, xcol);
Cell b15 = fila.getCell(15, xcol);

arreglo[xcol][0] = b0.getContents();
arreglo[xcol][1] = b1.getContents();
arreglo[xcol][2] = b2.getContents();
arreglo[xcol][3] = b3.getContents();
arreglo[xcol][4] = b4.getContents();
arreglo[xcol][5] = b5.getContents();
arreglo[xcol][6] = b6.getContents();
arreglo[xcol][7] = b7.getContents();
arreglo[xcol][8] = b8.getContents();
arreglo[xcol][9] = b9.getContents();
arreglo[xcol][10] = b10.getContents();
arreglo[xcol][11] = b11.getContents();
arreglo[xcol][12] = b12.getContents();
arreglo[xcol][13] = b13.getContents();
arreglo[xcol][14] = b14.getContents();

System.out.println(arreglo[xcol][0] + " " +
arreglo[xcol][1] + " " +
arreglo[xcol][2] + " " +
arreglo[xcol][3] + " " +
arreglo[xcol][4] + " " +
arreglo[xcol][5] + " " +
arreglo[xcol][6] + " " +
arreglo[xcol][7] + " " +
arreglo[xcol][8] + " " +
arreglo[xcol][9] + " " +
arreglo[xcol][10] + " " +
arreglo[xcol][11] + " " +
arreglo[xcol][12] + " " +
arreglo[xcol][13] + " " +
arreglo[xcol][14] + " " + "\t");

}
}
}
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:Como llamar un metodo entro de otro

Publicado por vegesoft (11 intervenciones) el 11/11/2009 22:56:36
En primer lugar no te da verguenza preguntar esa tonteria bueno te ayudare por que me has echo reir jajaja

public class Consulta {

Workbook archivo <--- variable global , dentro de un metodo es local

public void conexionXLS() throws IOException, BiffException{
archivo = Workbook.getWorkbook(new File("f:\\llamadas_mda_Octubre.xls"));
}

public void leerXLS() throws IOException, BiffException {
Sheet fila = archivo.getSheet(0); //esto hace referencia al metodo de arriba

Cell a0 = fila.getCell(0, 0);
Cell a1 = fila.getCell(1, 0);

.....
...
....
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:Como llamar un metodo entro de otro

Publicado por clkfgbd ksdfgbkjsd (1 intervención) el 04/03/2016 14:19:22
¿¿Y es que acaso usted nació aprendido ??, no le da vergüenza humillar a los demás sólo por que usted es menos ignorante en cierto tema??

me imagíno que será un experto en programación desde los 3 años de edad...
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar