如何吧EXCEL的数据从页面导入到数据库.
把原有的数据覆盖了.还有就是其中1个字段是金额覆盖以后再上45元.

解决方案 »

  1.   

    我这里只有将Excel中的数据读取到bean里面,其他操作你自己做做
    public static void main(String[] args) { try {
    FileInputStream fis = new FileInputStream(new File("d:/1.xls"));
    Workbook rwb = Workbook.getWorkbook(fis);
    Sheet rs = rwb.getSheet(0);
    int rows = rs.getRows();
    int columns = rs.getColumns(); int n = 0; // 定义几列,这里有三列
    int c = 1;
    int t = 2; for (int i = 1; i < rows; i++) {
    String name = rs.getCell(n, i).getContents().trim();
    String city = rs.getCell(c, i).getContents().trim();
    String address = rs.getCell(t, i).getContents().trim(); CouponBean coupon = new CouponBean(); coupon.setCity(city); coupon.setName(name); coupon.setAddress(address); System.out.println(coupon.getName() + "\t" + coupon.getCity()
    + "\t" + coupon.getAddress());
    }
    } catch (FileNotFoundException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } catch (BiffException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    }