首页 > 代码库 > spingmvc 上传文件, poi解析xls,xlsx
spingmvc 上传文件, poi解析xls,xlsx
前台jsp
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>数据导入</title> <style type="text/css"> </style> </head> <body> <div align="right"> <form action="<%=request.getContextPath()%>/loanData" method="POST" enctype="multipart/form-data"> <table class="table" id="queryCondition"> <tbody class="tbd"> <tr> <td align="right" style="padding-right: 2px"> <input type="file" name="myfiles" id="myfiles" style="display: none;" onchange="document.getElementById('filePath').value=http://www.mamicode.com/this.value" />>java代码,使用的包为poi3.5,commons-io2.1 import java.io.File; import java.io.IOException; import java.io.InputStream; import javax.servlet.http.HttpServletRequest; import org.apache.commons.io.FileUtils; import org.apache.poi.hssf.usermodel.HSSFCell; import org.apache.poi.hssf.usermodel.HSSFRow; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFCell; import org.apache.poi.xssf.usermodel.XSSFRow; import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.multipart.MultipartFile; @Controller public class HdImporController { @RequestMapping("/initLoanData") public String initLoanData(HttpServletRequest request) { return "views/service/import/loanData"; } @RequestMapping(value = http://www.mamicode.com/"/loanData", method = RequestMethod.POST)>spingmvc 上传文件, poi解析xls,xlsx
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。