一、下载引用
目前官网不能直接下载到引用的dll,需要自己打包(我没有自己打包,我有现成的DLL,地址:https://files.cnblogs.com/files/dengxixi/NPOIdll.7z),即:NPOI.dll,NPOI.OOXML.dll,NPOI.OpenXml4Net.dll,ICSharpCode.SharpZipLib.dll。(解压密码是:123456)
二、创建MVC项目,页面代码:
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>使用NPOI导入excel</title>
<script src="Scripts/jquery-1.8.2.min.js"></script>
<style>
.myFileUpload {
position: absolute;
display: block;
width: 100px;
height: 40px;
opacity: 0;
}
</style>
</head>
<body>
<div class="container">
<form class="form-horizontal" action="~/Home/Upload" role="form" method="post" enctype="multipart/form-data">
<table style="margin:5px;height:70px;">
<tr>
<td>请选择文件:</td>
<td width="5px;"></td>
<td><input type="file" id="fileUpload" name="fileUpload"></td>
<td><input id="fileText" type="text" class="myFileUpload" disabled="disabled" /></td>
<td><button type="submit">上传</button></td>
</tr>
</table>
</form>
</div>
</body>
</html>