Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException TreeMap

ساخت وبلاگ

Vote count: 0

enter code hereException in thread "AWT-EventQueue-0" java.lang.NullPointerException at dacia.Principale.jButton10ActionPerformed(Principale.java:1204) at dacia.Principale.access$500(Principale.java:44)

 XSSFWorkbook wg= new XSSFWorkbook(); XSSFSheet sht=wg.createSheet(); TreeMap<String,Object[]> data= new TreeMap<>(); // data.put("-1",new Object[]){"chasis","marque","couleur","nom client","date d entree","date sortie","telephone","numero WW","position","mode paiment","gamme","version"}); data.put("-1",new Object[]{jTable2.getColumnName(0),jTable2.getColumnName(1),jTable2.getColumnName(2),jTable2.getColumnName(3),jTable2.getColumnName(4),jTable2.getColumnName(5),jTable2.getColumnName(6),jTable2.getColumnName(7),jTable2.getColumnName(8),jTable2.getColumnName(9),jTable2.getColumnName(10),jTable2.getColumnName(11)}); for(int i=0;i<jTable2.getRowCount();i++) { data.put(Integer.toString(i),new Object[]{jTable2.getValueAt(i,0).toString(),jTable2.getValueAt(i,1).toString(),jTable2.getValueAt(i,2).toString(),jTable2.getValueAt(i,3).toString(),jTable2.getValueAt(i,4).toString(),jTable2.getValueAt(i,5).toString(),jTable2.getValueAt(i,6).toString(),jTable2.getValueAt(i,7).toString(),jTable2.getValueAt(i,8).toString(),jTable2.getValueAt(i,9).toString(),jTable2.getValueAt(i,10).toString(),jTable2.getValueAt(i,11).toString()}); } //write to excel Set <String> ids=data.keySet(); XSSFRow row ; int roow=0 ; for (String st : ids) { row=sht.createRow(roow++); Object[] values=data.get(st); int cellId=0 ; for(Object o : values) { Cell cell=row.createCell(cellId++); cell.setCellValue(o.toString()); } } try { //write to file FileOutputStream fos= new FileOutputStream(new File("/home/elprincipe/Desktop/dacia.xls")); wg.write(fos); fos.flush(); fos.close(); } catch (FileNotFoundException ex) { Logger.getLogger(Principale.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(Principale.class.getName()).log(Level.SEVERE, null, ex); }

the probleme is in data.put(Integer.toString(i),new Object[]{jTable2.getValueAt(i,0).toString(),jTable2.getValueAt(i,1).toString(),jTable2.getValueAt(i,2).toString(),jTable2.getValueAt(i,3).toString(),jTable2.getValueAt(i,4).toString(),jTable2.getValueAt(i,5).toString(),jTable2.getValueAt(i,6).toString(),jTable2.getValueAt(i,7).toString(),jTable2.getValueAt(i,8).toString(),jTable2.getValueAt(i,9).toString(),jTable2.getValueAt(i,10).toString(),jTable2.getValueAt(i,11).toString()});

asked 22 secs ago

back soft...
ما را در سایت back soft دنبال می کنید

برچسب : نویسنده : استخدام کار backsoft بازدید : 323 تاريخ : پنجشنبه 31 تير 1395 ساعت: 0:48