你不是可以得到他们的值了吗?把他们放在String里面,然后链接数据库,把它们插入数据库,看一些jdbc的知识把

解决方案 »

  1.   

    public boolean uploadExcelFile(String ExcelFileName){
           Workbook workBook = null;
           Cell[] cell = null;
           try{
               workBook = Workbook.getWorkbook(new FileInputStream(ExcelFileName));
           }catch(Exception ex){
             pub.setErrorStr(pub.rb.getString("Err.ExcelFileEmpty"));
           }
           Sheet sheet = workBook.getSheet(0);
           //int columnCount = 5;
          // for(int i = 0; i< columnCount; i++){
             //  cell = sheet.getColumn(i);
          // }
           int rowCount = sheet.getRows();
           //item1: Item item2:Desc item3 : mfgr item4 : mfgrp/n item5:ReceiptRouting
           Cell item1 = null;
           Cell item2 = null;
           Cell item3 = null;
           Cell item4 = null;
           Cell item5 = null;
           String itemValue1 = null;
           String itemValue2 = null;
           String itemValue3 = null;
           String itemValue4 = null;
           String itemValue5 = null;
           String pn_id = "";
           for(int i = 1; i < rowCount ; i++){
                   item1 = sheet.getCell(0,i);
                   item3 = sheet.getCell(2,i);
                   item4 = sheet.getCell(3,i);       itemValue1 = item1.getContents().toString();
           if(itemValue1 == null || itemValue1.equals("")){
                pub.setErrorStr("Item"+pub.rb.getString("Err.itemValueEmpty"));
                return false ;
            }        String sql = "SELECT pn_id FROM part_number WHERE part_number = '"+itemValue1+"' AND status =1";
            ArrayList result = pts.readFromTable(sql,1);
            if(result == null){
                pub.setErrorStr(pub.rb.getString("Err.ReadDb"));
                return false;
            }
            if(result.size() == 0){
                sql = "INSERT INTO part_number(part_number, description, customer_pn,log_time, status)"
                + " VALUES('"+itemValue1+"','','',INT4(EXTRACT(EPOCH FROM NOW())),1) ";
                 if (!pts.saveToTable(sql)) {
                 pub.setErrorStr(pub.rb.getString("Err.InsertDb"));
                return false;
                }
            }
            sql = "SELECT pn_id FROM part_number WHERE part_number = '"+itemValue1+"' AND status =1";
             result = pts.readFromTable(sql,1);
              if(result == null){
              pub.setErrorStr(pub.rb.getString("Err.ReadDb"));
              return false;
             }
             pn_id = result.get(0).toString();
             /*
             if (pts.checkDataExist("pn_id", pn_id, "status", "1", "pn_id", "part_number")) {
                 sql = "UPDATE part_number SET pn_id ='"+pn_id+"' AND status = 1";
                 if (!pts.saveToTable(sql)) {
                 //pub.setErrorStr(pub.rb.getString("Err.UpdateDb"));
                //return false;
                  continue;
                 }
             }*/
            //System.out.println(itemValue1);
            itemValue3 = item3.getContents().toString();
            if(itemValue3 == null || itemValue3.equals("")){
               pub.setErrorStr("mfgr"+pub.rb.getString("Err.itemValueEmpty"));
               return false ;
           }
            itemValue4 = item4.getContents().toString();
            if(itemValue4 == null || itemValue4.equals("")){
               pub.setErrorStr("mfgr_pn"+pub.rb.getString("Err.itemValueEmpty"));
               return false ;
           }
           System.out.println("itemValue1 : " + itemValue1 +"itemValue2 : "+itemValue3 +"itemValue3 :  "+itemValue4);
           if (pts.checkDataExist("pn_id", pn_id, "status", "1", "pn_id", "part_number")) {
                //sql = "UPDATE part_number SET pn_id ='"+pn_id+"' WHERE  pn_id ='"+pn_id+"' AND status = 1";
               // if (pts.saveToTable(sql)) {
                //pub.setErrorStr(pub.rb.getString("Err.UpdateDb"));
               //return false;
                getSaveAMLRecordCmd(pn_id,itemValue3,itemValue4);
                 continue;
              //  }
            }     // getSaveAMLRecordCmd(pn_id,itemValue3,itemValue4);
         }    workBook.close();
        return true;
       }
    谢谢楼主,我已经解决了,thanks