小笨鸟要先飞_ 2011-01-23 20:06
浏览 201
已采纳

关于jxl将Excel中的数据读取到数据库中保存

主要功能如下:

用户点击上传Excel, 上传完了 就直接用Jxl读取到数据库中 本人从未接触过Jxl 没头绪。 希望那个可以把思路告诉我下。

最好是有源代码。 谢谢 邮箱xiayang730@sohu.com :cry:

  • 写回答

2条回答 默认 最新

  • nishinimas 2011-01-24 15:33
    关注

    try {
    // if (fileName != null && fileName.endsWith(".xls")) {
    // if (null != myFile) {
    // File file = new File(FrontConstant.getInstance()
    // .getUploadTestPath()
    // + fileName);
    // FormatUtil.copy(myFile, file);
    // }
    // String path = FrontConstant.getInstance().getUploadTestPath()
    // + fileName;
    // Workbook book = Workbook.getWorkbook(new File(path));
    // // get a Sheet object.
    // Sheet sheet = book.getSheet(0);
    // // 获取行数
    // int rows = sheet.getRows();
    // String testId = "", score = "", type = "";
    // for (int i = 1; i < rows; i++) {
    // System.out.println(sheet.getCell(1, 1).getContents());
    // testId = sheet.getCell(0, i).getContents();
    // score = sheet.getCell(4, i).getContents();
    // type = sheet.getCell(5, i).getContents();
    // // }
    // book.close();
    // //

    }
    // } catch (Exception e) {
    // e.printStackTrace();
    // //

    }

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?