Package org.apache.poi

blokisso Messages postés 2 Date d'inscription vendredi 20 avril 2012 Statut Membre Dernière intervention 25 juin 2012 - 25 juin 2012 à 13:50
 Utilisateur anonyme - 26 juin 2012 à 12:09
bonjour, j'ai un probleme avec des packages. mon IDE Eclipse n'arrive pas de les reconnaitre. voici le code.
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
// c'est cette partie org.apache.poi.
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;

public class ExportJ {



public static void main(String[] args) {

HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("Bordereau");
int a = jTable1.getRowCount();
int b =jTable1.getColumnCount();
HSSFRow ro = sheet.createRow(0);
ro.createCell((short)0, HSSFCell.CELL_TYPE_STRING)
.setCellValue(new HSSFRichTextString("N°Bordereau"));
ro.createCell((short)1, HSSFCell.CELL_TYPE_STRING)
.setCellValue(new HSSFRichTextString("Date"));
ro.createCell((short)2, HSSFCell.CELL_TYPE_STRING)
.setCellValue(new HSSFRichTextString("Banque"));
ro.createCell((short)3, HSSFCell.CELL_TYPE_STRING)
.setCellValue(new HSSFRichTextString("N°Compte"));
ro.createCell((short)4, HSSFCell.CELL_TYPE_STRING)
.setCellValue(new HSSFRichTextString("N°Bordereau Banque"));
ro.createCell((short)5, HSSFCell.CELL_TYPE_STRING)
.setCellValue(new HSSFRichTextString("Nature"));
ro.createCell((short)6, HSSFCell.CELL_TYPE_STRING)
.setCellValue(new HSSFRichTextString("Gestion"));
for(int i=1;i<a;i++)
{
ro = sheet.createRow(i);
for(int j=0;j<b;j++)
{
HSSFCell cell = ro.createCell((short)j);

Object o = jTable1.getValueAt(i,j);
if(o instanceof String)
cell.setCellValue((String)o);
else if(o instanceof Double)
cell.setCellValue((Double)o);
else if(o instanceof Integer)
cell.setCellValue((Integer)o);
else if(o instanceof Date)
cell.setCellValue((Date)o);
//cell.setCellValue(jTable1.getValueAt(i,j));
}
}

FileOutputStream fileOut;
try {
fileOut = new FileOutputStream("D:\\NetBeansProjects\\Projet\\BOR.xls");
wb.write(fileOut);
fileOut.close();
Runtime.getRuntime().exec("C:\\Program Files\\Microsoft Office\\OFFICE11\\EXCEL.EXE D:\\NetBeansProjects\\Projet\\BOR.xls" );
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}



c'est la partie import org.apache.poi.
Je vous remercie
A voir également:

2 réponses

cs_jojolemariole Messages postés 519 Date d'inscription mercredi 21 mars 2007 Statut Membre Dernière intervention 19 décembre 2016 25
25 juin 2012 à 14:08
Il faut que tu ajoutes la ou les librairies dans ton classpath (clic droit sur le projet > configure buildpath).
0
Utilisateur anonyme
26 juin 2012 à 12:09
Et après (de mémoire), "Add external Jar file" (ou un truc du genre), et là tu sélectionnes le Jar qui contient le code que tu n'arrives pas à importer.


--
Pylouq
(Lire le Réglement n'a jamais tué personne, au pire ça a instruit des gens.)
0
Rejoignez-nous