poi读取2003正常,为什么读取不到2007的

J2EE 码拜 9年前 (2015-04-05) 755次浏览 0个评论
 

controller

/**
	 * 读者批导入EXCEL接收
	 * @param model
	 * @return
	 * @throws IOException 
	 * @throws FileNotFoundException 
	 * @throws InvalidFormatException 
	 */
	@RequestMapping("/upload")
	public String upload(@RequestParam("file") MultipartFile file , Model model) throws InvalidFormatException, FileNotFoundException, IOException{
		try {
			String filePath = Config.parseFilePath(
					"window.bookSellerReceive.file",
					"window.bookSellerReceive.file", file);
				excelImp.initWorkbook(new FileInputStream(new File(filePath)));
				Map<String,String> map = excelImp.readerTitle(0).getTitles();
				model.addAttribute("sheetNameInfos", map);
				model.addAttribute("filePath", filePath);
				return MANA_PATH + "readerupload/sheetUpload";
		} catch (BusinessException e) {
			model.addAttribute(Constant.MESSAGE_ERROR, e.getMessage());
			e.printStackTrace();
			return list(model);
		} 
	}

excel工具类

	/**
	 * <p>
	 * description:创建工作本
	 * </p>
	 * 
	 * @param inp
	 * @return
	 * @throws InvalidFormatException
	 * @throws IOException
	 * @return Workbook
	 * @date 2012-7-2
	 */
	public void initWorkbook(InputStream inp) throws InvalidFormatException,
			IOException {
		workbook = WorkbookFactory.create(inp);
	}

readerTitle

public ExcelTitle readerTitle(int sheetNumber) {
		return readerTitle(sheetNumber, null);
	}

debug是在

excelImp.initWorkbook(new FileInputStream(new File(filePath)));

看半天看不出哪有问题2003接收正常 2007就失败了

poi读取2003正常,为什么读取不到2007的
2分
2003和2007的API是不一样的
poi读取2003正常,为什么读取不到2007的
5分
WorkbookFactory.create(inp);
既可创建HSSFWorkbook(.xls),也可创建XSSFWorkbook(.xlsx)。你具体报什么错?
poi读取2003正常,为什么读取不到2007的
5分
应该是版本问题吧,对2003的操作和2007的操作是不一样的
poi读取2003正常,为什么读取不到2007的
5分
删除xbean-2.1.0.jar这个包

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明poi读取2003正常,为什么读取不到2007的
喜欢 (0)
[1034331897@qq.com]
分享 (0)

文章评论已关闭!