Boa tarde, Gostaria de saber como faz para ler dados de uma planilha excel se alguem puder me ajudar
Basta usar a API POI:
Para aprender basta ver os exemplos no javadoc ou faq:
http://poi.apache.org/faq.html
Abraço
Eu consegui ler o arquivo do excel porem nao estou conseguindo printar nenhuma string se vocês puderem me ajudar o codigo é esse
[code] Workbook w = Workbook.getWorkbook(new File(“C:\teste.xls”));
Sheet sheet = w.getSheet(0);
System.out.println(sheet.getRows());
System.out.println(sheet.getColumns());
w.close();[/code]
Ja sei quantas colunas e quantas linhas tem o arquivo
Bem galera, eu consegui pega ler a planilha de excel com varios emails e gravar em um arquivo txt vou passar a soluçao ai
[code]public static void main(String[] args ) throws IOException, BiffException,
ClassNotFoundException {
Workbook w = Workbook.getWorkbook(new File("C:\teste.xls"));
String a ="";
Sheet sheet = w.getSheet(0);
for(int i = 0;i<sheet.getRows();i++){
Cell c=sheet.getCell(0,i);
a+=c.getContents();
}
Scanner scan = new Scanner(a);
String readLine="";
String conteudo = "";
while (scan.hasNext()) {
readLine = scan.next();
if(readLine.contains("@")){
String[] b = readLine.split(",");
conteudo += b[0]+"\r\n";
}
}
File file = new File("C:\email.txt");
FileOutputStream fo = new FileOutputStream(file,false);
fo.write(conteudo.replace("<", "").replace(">", "").replace("\"","").getBytes());
w.close();
}[/code]