我正在从浏览器上传一个excel文件.我正在使用POI jar.但是得到错误
标头签名无效;阅读3255307777713450285,预计-2226271756974174256
标头签名无效;阅读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>
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()); }
但是在POIFSFileSystem myFileSystem =新的POIFSFileSystem(文件)中获取错误;
如何解决这个问题?