小编Swe*_*eam的帖子

Excel读取错误:标头签名无效.怎么解决?

我正在从浏览器上传一个excel文件.我正在使用POI jar.但是获得错误无效的头部签名; 阅读3255307777713450285,预计-2226271756974174256

在我使用的两个jsp文件下面:JSP 1:

<form action="Upload.jsp" enctype="MULTIPART/FORM-DATA" method=post >
  <input type="file" name="filename" />
  <input type="submit" value="Upload" />
</form>
Run Code Online (Sandbox Code Playgroud)

JSP 2:Upload.jsp

try{
        InputStream file = request.getInputStream();
        POIFSFileSystem myFileSystem = new POIFSFileSystem(file);
        HSSFWorkbook myWorkBook = new HSSFWorkbook(myFileSystem);
        HSSFSheet mySheet = myWorkBook.getSheetAt(0);
        Iterator rowIter = mySheet.rowIterator();
        rowIter.next(); 
        while (rowIter.hasNext()) {
            HSSFRow myRow = (HSSFRow) rowIter.next();
            Iterator cellIter = myRow.cellIterator();
            cellIter.next();
            System.out.println(((HSSFCell)cellIter.next()).toString());
        }


    }catch(Exception ex){
        System.out.println(ex.getMessage());
    }
Run Code Online (Sandbox Code Playgroud)

但是在POIFSFileSystem myFileSystem =新的POIFSFileSystem(文件)中获取错误;

如何解决这个问题?

java excel file-upload apache-poi

6
推荐指数
1
解决办法
2万
查看次数

如何为com.sun.tools.javac.Main.compile()函数设置classpath?

我正在使用com.sun.tools.javac.Main.compile()函数从我的struts项目运行时编译java文件.但对于某些文件,他们需要一些像axis2这样的特定罐子.我有罐子但是如何将它们设置为classpath以在运行时编译java文件?我试过System.setProperty("java.class.path","jar dir");但但没能编译.

java compiler-errors jar

6
推荐指数
1
解决办法
4577
查看次数

标签 统计

java ×2

apache-poi ×1

compiler-errors ×1

excel ×1

file-upload ×1

jar ×1