实习狗的每天新知识日常
准备工作:
1.在项目中添加对NPOI的引用,NPOI下载地址:http://npoi.codeplex.com/releases/view/38113
2.NPOI学习系列教程推荐:http://www.cnblogs.com/tonyqus/archive/2009/04/12/1434209.html
NPOI下载,里面有五个dll,需要引用到你的项目,我这边用的mvc4+三层的方式架构的项目
我用的工具是(vs2012+sql2014)
准备工作做完,我们开始进入主题
1.前端页面,代码:
<div class="filebtn"> @using (Html.BeginForm("importexcel", "foot", FormMethod.Post, new { enctype = "multipart/form-data" })) { <samp>请选择要上传的Excel文件:</samp> <span id="txt_Path"></span> <strong>选择文件<input name="file" type="file" id="file" /></strong>@* @Html.AntiForgeryToken() //防止跨站请求伪造(CSRF:Cross-site request forgery)攻击 *@<input type="submit" id="ButtonUpload" value="提交" class="offer"/> } </div>