|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Senior Member
Iscritto dal: May 2009
Messaggi: 366
|
[JAVA] output su documento excel
salve ragazzi ho questo problema devo restituire l' output di una matrice in una tabella di un documento excel si potrebbe fare grazie ciao.
__________________
visitate http://www.forumsenzacontro.altervista.org |
|
|
|
|
|
#2 |
|
Senior Member
Iscritto dal: Oct 2007
Città: Padova
Messaggi: 4131
|
Con Googleho trovato questa libreria, se devi lavorare anche in futuro con Excel potrebbe farti comodo: JExcelAPI.
Qui c'è un tutorial. Però dal tuo messaggio mi par di capire che ti serve veramente una funzionalità minima. Magari potresti stampare la tua matrice su un file di testo in formato csv (comma separated values): Excel è in grado di leggere files in questo formato.
__________________
As long as you are basically literate in programming, you should be able to express any logical relationship you understand. If you don’t understand a logical relationship, you can use the attempt to program it as a means to learn about it. (Chris Crawford) Ultima modifica di banryu79 : 15-10-2009 alle 17:48. |
|
|
|
|
|
#3 |
|
Senior Member
Iscritto dal: May 2009
Messaggi: 366
|
ho dato un 'occhiata al tutorial ma ti dice solo come creare un nuovo file excel io dovrei prendere un file excel già esistente e modificarlo
__________________
visitate http://www.forumsenzacontro.altervista.org |
|
|
|
|
|
#4 | |
|
Senior Member
Iscritto dal: Oct 2007
Città: Padova
Messaggi: 4131
|
Quote:
Tra l'altro leggendo l'"indice" del tutorial ci sono sezioni specifiche tipo "Copying and Modifying Spreadsheets", per dire. Se hai dubbi più specifici l'unica è studiarsi un attimo le API della libreria. @EDIT P.S.: a partire dalla home page di JExcelAPI trovi vari link di documentazione utili, vedi le FAQ.
__________________
As long as you are basically literate in programming, you should be able to express any logical relationship you understand. If you don’t understand a logical relationship, you can use the attempt to program it as a means to learn about it. (Chris Crawford) Ultima modifica di banryu79 : 20-10-2009 alle 16:44. |
|
|
|
|
|
|
#5 |
|
Senior Member
Iscritto dal: Apr 2002
Città: Palermo
Messaggi: 4913
|
Ciao, se posso, ti consiglio di usare la libreria apache poi.
In questo link c'è veramente tutto quello che ti serve. Ciao p.s Ti aggiungo un metodino per leggere un excel riga per riga Codice:
public String leggiRiga(int i){
HSSFRow row = sheet.getRow(i);
if (row == null) return null;
Iterator<HSSFCell> itCells = row.cellIterator();
String riga = "";
while(itCells.hasNext()){
String campo = "";
HSSFCell cella = itCells.next();
switch (cella.getCellType()) {
case HSSFCell.CELL_TYPE_STRING:
campo = cella.getRichStringCellValue().toString();
// System.out.println("STRING "+cella.getRichStringCellValue());
break;
case HSSFCell.CELL_TYPE_NUMERIC:
if(HSSFDateUtil.isCellDateFormatted(cella)){
campo = sdf.format(cella.getDateCellValue());
// System.out.println("DATA "+cella.getDateCellValue());
}else{
campo = String.valueOf(cella.getNumericCellValue());
// System.out.println("NUMERICO "+cella.getNumericCellValue());
}
break;
default:
campo = " ";
// System.out.println("NESSUNA");
break;
}
riga = riga + ";" +campo;
}
return riga.substring(1);
}
HSSFSheet sheet = workBook.getSheetAt(0); e poi iterare direttamente sulle righe (e quindi poi sulle celle) con Iterator<HSSFSheet> workBook.rowIterator() e poi Iterator<HSSFCell> itCells = row.cellIterator(); bye
__________________
Sun Certified Java Programmer - Sun Certified Web Component Developer - Sun Certified Business Component Developer Ultima modifica di gokan : 20-10-2009 alle 19:55. |
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 05:44.



















