can19850 2009-03-29 04:00
浏览 312
已采纳

java jxl excel导入数据库

java.lang.Error: Unresolved compilation problems:
ServletActionContext cannot be resolved
The type List is not generic; it cannot be parameterized with arguments
Syntax error, parameterized types are only available if source level is 5.0
ArrayList cannot be resolved to a type
Syntax error, parameterized types are only available if source level is 5.0
The type List is not generic; it cannot be parameterized with arguments
Syntax error, parameterized types are only available if source level is 5.0
ArrayList cannot be resolved to a type
Syntax error, parameterized types are only available if source level is 5.0
ActionContext cannot be resolved
SysConstant cannot be resolved
log cannot be resolved
filePath cannot be resolved
filePath cannot be resolved
Constants cannot be resolved
carInsModificationFacade cannot be resolved
filePath cannot be resolved
Constants cannot be resolved
FacadeException cannot be resolved to a type
e cannot be resolved
e cannot be resolved
The type List is not generic; it cannot be parameterized with arguments
Syntax error, parameterized types are only available if source level is 5.0
The type List is not generic; it cannot be parameterized with arguments
Syntax error, parameterized types are only available if source level is 5.0
FacadeException cannot be resolved to a type
log cannot be resolved
InputStream cannot be resolved to a type
FileInputStream cannot be resolved to a type
Workbook cannot be resolved to a type
Workbook cannot be resolved
Sheet cannot be resolved to a type
The type List is not generic; it cannot be parameterized with arguments
Syntax error, parameterized types are only available if source level is 5.0
ArrayList cannot be resolved to a type
Syntax error, parameterized types are only available if source level is 5.0
CarInsModificationInfo cannot be resolved to a type
CarInsModificationInfo cannot be resolved to a type
StringUtils cannot be resolved
Pattern cannot be resolved
Pattern cannot be resolved
carInsModificationDAO cannot be resolved
carInsModificationDAO cannot be resolved
StringUtils cannot be resolved
StringUtils cannot be resolved
StringUtils cannot be resolved
StringUtils cannot be resolved
carInsModificationDAO cannot be resolved
CmodiType cannot be resolved to a type
CmodiType cannot be resolved to a type
StringUtils cannot be resolved
StringUtils cannot be resolved
Date cannot be resolved to a type
DateFormater cannot be resolved
DateFormater cannot be resolved
Date cannot be resolved to a type
carInsModificationDAO cannot be resolved
FacadeException cannot be resolved to a type
log cannot be resolved

at util.ExcelServlet.<init>(ExcelServlet.java:40)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1104)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:806)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:129)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source)

log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
2009-3-29 3:51:38 org.apache.catalina.core.StandardWrapperValve invoke
信息: Servlet ExcelServlet is currently unavailable

代码是:

public class ExcelServlet extends HttpServlet {

public ExcelServlet() {
    super();
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    doPost(request, response);      
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    File file = new File("C:/adminexcel.xls");
    try {
        System.out.println(read(file));
    } catch (Exception e) {
        System.out.println(e.getMessage());
    }
}

public static String read(File file) throws Exception {
    StringBuffer sb = new StringBuffer();   
    Workbook wb = null;
    try {
        wb = Workbook.getWorkbook(file);
        if (wb != null) {
            Sheet[] sheets = wb.getSheets();
            if (sheets != null && sheets.length != 0) {
                for (int i=0;i<sheets.length;i++) {
                    int rows = sheets[i].getRows();
                    for (int j=0;j<rows;j++) {
                     Cell[] cells = sheets[i].getRow(j);
                        if (cells != null && cells.length != 0) {
                            for (int k=0;k<cells.length;k++) {
                                String cell = cells[k].getContents();
                            System.out.println(cell);
                                sb.append(cell + "\t");
                            }
                            sb.append("\t\n");
                        }
                    }
                    sb.append("\t\n");
                }
            }
            System.out.println("成功" + file + "\n");
        }
    } catch (Exception e) {
        System.out.println(e.getMessage());
    } finally {
        wb.close();
    }
    return sb.toString();
}

}

  • 写回答

3条回答 默认 最新

  • lijunjieone 2009-03-29 23:16
    关注

    http://lijunjie.iteye.com/admin/blogs/348747
    我这个也是用jxl处理的

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

报告相同问题?

悬赏问题

  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥30 python代码,帮调试,帮帮忙吧