1.  html

<form id="form_search" action="@Url.Action("UpLoadFile")" enctype="multipart/form-data" method="post">

<td>
                                上传文件:<input class="easyui-filebox" id="fileTxt" name="fileName" style=" width:200px" data-options="prompt:'Choose a file...'" />
                                <a id="UpLoadFile" class="easyui-linkbutton" style="" data-options="iconCls:'icon-fresh',width:70" onclick="upLoadFile()">
                                    上传
                                </a>
                            </td>
                            <script>
                                $('#fileTxt').filebox({
                                    buttonText: '选择文件',
                                    buttonAlign: 'right'
                                })
                            </script>

2.JavaScript

//文件上传
       function upLoadFile() {
        $("#UpLoadFile").click(function () {
            debugger;
            var upfile = $("#fileTxt").filebox("getValue");
            if (upfile.length <= 0) {
                $.mapuni.tips("请选择要上传的文件");
                return;
            }
            var ext = upfile.split('.');
            //$("#searchForm_dg").submit()
            $("#form_search").ajaxSubmit(function (message) {
                alert(message);
                window.location.reload();
            });
        });
    }

3.后台

public string UpLoadFile()
        {
            HttpPostedFileBase file = Request.Files["fileName"];
            string fileName = Path.GetFileName(file.FileName);
            string fileExt = Path.GetExtension(fileName);
            if (fileExt == ".xls" || fileExt == ".xlsx")
            {
                //string dir=excelPath    
                Directory.CreateDirectory(Path.GetDirectoryName(excelPath));
                string fullDir = excelPath + fileName;
                file.SaveAs(fullDir);
                return "文件保存成功";
            }
            else
            {
                return "文件保存失败";
            }
        }

private string excelPath = ConfigurationManager.AppSettings["DailyPublicationFilePath"];//"D:\\Test\\";//上传到服务器的路径

4.配置文件  AppSettingConfig.xml

<!--上传excel存放路径-->
  <add key="ExcelFilePath" value="D:\HeNan\" />

excel数据批量导入的更多相关文章

  1. Java实现Excel数据批量导入数据库

    Java实现Excel数据批量导入数据库 概述: 这个小工具类是工作中的一个小插曲哦,因为提数的时候需要跨数据库导数... 有的是需要从oracle导入mysql ,有的是从mysql导入oracle ...

  2. Excel数据批量导入到数据库

    1.今天做批量导入网上找了个例子,改了改,运行起来了.用POI实现Excel的读取,需要jar包. 2.ReadExcel.java读取数据 /** * */ package com.b510.exc ...

  3. 关于Excel数据批量导入数据库的案例

    写这个案例主要是感觉这个功能挺实用,很多地方会用得到的,废话就不多说了,直接上对应的源码. 这个案例我运用的是Winform窗体程序实现数据的导入. 首先是数据库的登陆界面如下: 源码如下: usin ...

  4. Excel数据批量导入到SqlServer的方法

    1,以Excel为数据源建立连接导入. 关键点在于Excel的数据要有表头,表头要和数据库表的列名一样.连接字符串中HDR=YES不能省略,也就是第一行是表头的意思.IMEX=1;是把数据都当作字符串 ...

  5. 使用python,将excel数据批量导入数据库

    这是上一篇文章的优化版本,相较于一条一条的执行sql语句,本文中,将excel中所有的数据先写到list列表中 在通过函数 cursor.executemany(sql, list) 一次性写入到数据 ...

  6. Excel数据批量导入到数据库2

    1.导包(共3个) 2.jsp <s:form action="ReadExcel.action" method="post" enctype=" ...

  7. 将Excle中的数据批量导入数据库

    namespace 将Excle中的数据批量导入数据库{    class Program    {        static void Main(string[] args)        { S ...

  8. 将execl里的数据批量导入数据库

    本文将采用NPOI插件来读取execl文件里的数据,将数据加载到内存中的DataTable中 /// <summary> /// 将Excel转换为DataTable /// </s ...

  9. SqlServer表和excel数据批量复制方法

    SqlServer表和excel数据批量复制方法 一.SqlServer表数据复制到excel方法: 1.新建查询,用sql语句把表数据读出来 2.然后,选择数据,右键“复制”(如果需要表字段名称,则 ...

随机推荐

  1. redis 3.2.3的源码安装

    Install necessary packages On CentOS : yum install wget make gcc tcl On CentOS yum install wget make ...

  2. Push UIViewController with different orientation to previous

    转自:http://stackoverflow.com/questions/6695837/push-uiviewcontroller-with-different-orientation-to-pr ...

  3. 源码安装mysql5.6x启动报错:[ERROR] Can't find messagefile '/data/mysqldata/3306/english/errmsg.sys'

    :: mysqld_safe Starting mysqld daemon with databases from /data/mysqldata//data -- :: [Warning] The ...

  4. HTML5学习笔记(十七):访问器和class关键字

    访问器 在ECMAScript5中,提供了Object.defineProperty的方法,我们可以通过该方法来控制属性的更多权限. 属性类型 我们先看一段定义属性的代码: var person = ...

  5. How do I measure JVM startup time?

    https://stackoverflow.com/questions/39321345/how-do-i-measure-jvm-startup-time PrintCompilation2 htt ...

  6. bat批处理延迟运行脚本

    @echo off:aaapause 这里是你需要运行的程序for /l %%i in (0,1,10000) do echo %%i>nulgoto aaa 当然bat延迟运行还有其他的一些方 ...

  7. 每日英语:Political Gridlock, Beijing Style

    To admirers outside the country, China's political system stands far above the dysfunctional democra ...

  8. [整理]Unity3D游戏开发之Lua

    原文1:[Unity3D]Unity3D游戏开发之Lua与游戏的不解之缘(上) 各位朋友,大家好,我是秦元培,欢迎大家关注我的博客,我地博客地址是blog.csdn.net/qinyuanpei.如果 ...

  9. String.format和MessageFormat.format的对比用法

    1.MessageFormat.format import java.text.MessageFormat; /** * Created by SYJ on 2017/9/13. */ public ...

  10. Java运行时动态加载类之ClassLoader

    https://blog.csdn.net/fjssharpsword/article/details/64922083 *************************************** ...