惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Microsoft Azure Blog
Microsoft Azure Blog
WordPress大学
WordPress大学
小众软件
小众软件
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
V2EX
Hugging Face - Blog
Hugging Face - Blog
美团技术团队
博客园 - 三生石上(FineUI控件)
Last Week in AI
Last Week in AI
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - Franky
Microsoft Security Blog
Microsoft Security Blog
Y
Y Combinator Blog
A
About on SuperTechFans
The GitHub Blog
The GitHub Blog
U
Unit 42
H
Hackread – Cybersecurity News, Data Breaches, AI and More
云风的 BLOG
云风的 BLOG
IT之家
IT之家
MyScale Blog
MyScale Blog
V
Visual Studio Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
I
InfoQ
博客园 - 司徒正美

博客园 - Gerald1983

[转载]AJAX 框架 用 Asp.net ajax 还是 Jquery ? [转]触发器 Excel导出报错 Delete File - Gerald1983 - 博客园 SQLServer Service Can't Start - Gerald1983 SQL - Using CASE in a JOIN SQL SERVER 与ACCESS、EXCEL的导入导出(转载) Asp.net页面的生命周期 Asp.net页面的生命周期 DataGrid /GridView分页(sqlserver/oracle)-----转载 sql语句中包括单引号和双引号的问题 XmlDocument操作xml文档 (转) Ajax实例转载 一个Ajax实例(成本项目) Oracle存储过程编写经验和优化措施(转) GridView的美化 数据绑定时的前台页面上的逻辑判断 (转) 如何去掉DataTable中的重复行(新增.net 2.0中最新解决方法---简便) (转) C#代码与javaScript函数的相互调用(转)
DataSource of GridView is Excel - Gerald1983
Gerald1983 · 2008-10-21 · via 博客园 - Gerald1983

前台:

   <div>
            <table style="border-right: medium none; border-top: medium none; border-left: medium none;
                border-bottom: medium none" class="BillTable" cellspacing="0" cellpadding="0"
                width="100%">
                <caption style="border-right: medium none; border-top: medium none; border-left: medium none;
                    border-bottom: medium none">
                    <br />
                    <asp:Label ID="kk" runat="server" Text=" 江苏公司网络部-核心网专业室员工“卓越与进步”表扬档案记录榜" Font-Bold="true"
                        Font-Size="25px"></asp:Label>
                </caption>
                <tbody>
                </tbody>
            </table>
            <asp:SGridView ID="sgvPerson" runat="server" PageSize="5" AllowPaging="true" OnPageIndexChanging="sgvPerson_PageIndexChanging">
            </asp:SGridView>
        </div>

后台:

 protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("http://www.cnblogs.com/AttacheFile/核心网室员工《卓越与进步》表扬档案记录榜080927.xls") + "; Extended Properties=Excel 8.0;";
            OleDbConnection objConn = new OleDbConnection(strConn);
            objConn.Open();
            OleDbCommand objCmd = new OleDbCommand("select * from [sheet1$]", objConn);
            OleDbDataAdapter objAdapter = new OleDbDataAdapter();
            objAdapter.SelectCommand = objCmd;
            DataSet ds = new DataSet();
            objAdapter.Fill(ds, "XLSData");
            sgvPerson.DataSource = ds.Tables[0].DefaultView;
            sgvPerson.DataBind();
            GridViewDS = ds;
            objConn.Close();
            sgvPerson.Columns[8].ItemStyle.Wrap = false;
            sgvPerson.Columns[2].ItemStyle.Wrap = false;
            sgvPerson.Columns[3].ItemStyle.Wrap = false;
            sgvPerson.Columns[4].ItemStyle.Wrap = false;
        }
    }