亚洲免费乱码视频,日韩 欧美 国产 动漫 一区,97在线观看免费视频播国产,中文字幕亚洲图片

      1. <legend id="ppnor"></legend>

      2. 
        
        <sup id="ppnor"><input id="ppnor"></input></sup>
        <s id="ppnor"></s>

        asp.net中上傳并讀取excel文件數(shù)據(jù)示例

        字號:


            如何打開excel數(shù)據(jù)庫文件,想必有很多朋友都不清楚吧,下面通過一個簡單的例子,實現(xiàn)讀取excel數(shù)據(jù)文件
            在csdn中,經(jīng)常有人問如何打開excel數(shù)據(jù)庫文件。本文通過一個簡單的例子,實現(xiàn)讀取excel數(shù)據(jù)文件。
            首先,創(chuàng)建一個web應用程序項目,在web頁中添加一個datagrid控件、一個文件控件和一個按鈕控件。
            代碼如下:
            <input id=file1 type=file name=file1 runat=server>
            <asp:button id=button1 runat=server text=button></asp:button>
            <asp:datagrid id=datagrid1 runat=server></asp:datagrid>
            在代碼視圖中首先導入oledb命名空間:
            using system.data.oledb;
            在按鈕的單擊事件中輸入如下代碼:
            代碼如下:
            string strpath=c://test// + datetime.now.tostring(yyyymmddhhmmss) + .xls;
            file1.postedfile.saveas(strpath);
            string mystring=provider = microsoft.jet.oledb.4.0 ; data source = '+ strpath +';extended properties=excel 8.0;
            oledbconnection cnnxls = new oledbconnection (mystring);
            oledbdataadapter myda =new oledbdataadapter(select * from [sheet1$],cnnxls);
            dataset myds =new dataset();
            myda.fill(myds);
            datagrid1.datasource=myds.tables[0];
            datagrid1.databind();
            其中c:/test對aspnet用戶要有讀寫的權限.