Jump to content
Fórum Script Brasil
  • 0

Como colocar os valores do excel em um arraylist em java?


sivio

Question

Eu consegui colocar o nome mais eu não estou consegundo colocar o id e a categoria.Como devo fazer para colocar o valor do id e da categoria no comando abaixo?:

"PlanoDeSaude FP1 = new PlanoDeSaude(cell.toString(),cell1.toStr…

package domain;

public class PlanoDeSaude {

int id;

String nome;

Categoria categoria;

public PlanoDeSaude(int id, String nome){

this.id = id;

this.nome = nome;

}

public void setId(int id) {

this.id = id;

}

public int getId() {

return id;

}

public void setNome(String nome) {

this.nome = nome;

}

public String getNome() {

return nome;

}

public void setCategoria(Categoria categoria) {

this.categoria = categoria;

}

public Categoria getCategoria() {

return categoria;

}

}

}

package domain;

public enum Categoria {

A,B,C,D,E;

}

package teste;

import domain.*;

import java.io.IOException;

import java.util.ArrayList;

import org.apache.poi.hssf.usermodel.HSSFRow;

import org.apache.poi.hssf.usermodel.HSSFSheet;

import org.apache.poi.hssf.util.CellReference;

import org.apache.poi.ss.usermodel.Cell;

import org.apache.poi.ss.usermodel.CellValue;

import org.apache.poi.ss.usermodel.DateUtil;

import org.apache.poi.ss.usermodel.Row;

import org.apache.poi.ss.usermodel.Sheet;

import org.apache.poi.ss.usermodel.Workbook;

import org.apache.poi.xssf.usermodel.XSSFWorkbo…

import org.junit.Test;

public class TestePlanoDeSaude {

@Test

public void ler() throws IOException{

Workbook wb =new XSSFWorkbook(getClass().getResourceAsStr…

Sheet sheet1 = wb.getSheetAt(1);

Row row = sheet1.getRow(1);

Cell cell = row.getCell(0);

Row row1 = sheet1.getRow(1);

Cell cell1 = row.getCell(1);

Row row2 = sheet1.getRow(1);

Cell cell2 = row.getCell(2);

PlanoDeSaude FP1 = new PlanoDeSaude(cell.toString(),cell1.toStr…

ArrayList<PlanoDeSaude> lista = new ArrayList<PlanoDeSaude>();

lista.add(FP1);

for(int i = 0;i<lista.size();i++){

System.out.println(lista.get(i).getId())…

System.out.println(lista.get(i).getNome(…

System.out.println(lista.get(i).getCateg…

}

}

}

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.2k
    • Total Posts
      652k
×
×
  • Create New...