In una discussione trovata in questo forum ho trovato delle info su come lavorare su file excel. Quindi ho scaricato il pacchetto jexcelapi2_6_9 ho importato il file jxl.jar ed ho scritto questo codice:
Ottengo diversi errori di "Unhandled exception type BiffException" e "Unhandled exception type IOException".codice:import jxl.*; import java.io.*; ............. String buff = ""; //apro il file Workbook workbook = Workbook.getWorkbook(new File("C:/Documents and Settings/Sasori/Desktop/demofile.xls")); //BIFF & IOException //prendo il primo foglio Sheet sheet = workbook.getSheet(0); boolean flag1 = true; boolean flag2 = true; int riga = 0; Cell currentCell; while (flag1) { //leggo per righe int cella = 0; while (flag2) { //leggo le celle currentCell = sheet.getCell(cella, riga); flag2 = currentCell.getContents()== "" ? false : true; buff += currentCell.getContents(); cella++; } buff += "\n"; cella = 0; riga++; flag2 = true; currentCell = sheet.getCell(cella, riga); flag1 = currentCell.getContents() == "" ? false : true; } BufferedWriter br = new BufferedWriter(new FileWriter("C:/Documents and Settings/Andrea/Desktop/EXCEL.TXT")); br.write(buff); //IOException br.flush(); //IOException br.close(); //IOException
La discussione era postata da Andrea1979... qualcuno sa dirmi dove sbaglio??
Grazie

Rispondi quotando