国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 編程 > .NET > 正文

ASP.NET:訪問(wèn)Excel 電子表格

2024-07-10 13:07:48
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友
  • 本文來(lái)源于網(wǎng)頁(yè)設(shè)計(jì)愛(ài)好者web開發(fā)社區(qū)http://www.html.org.cn收集整理,歡迎訪問(wèn)。
  • c# code
    ---------------------------------------------
    <%@ page language="c#" %>
    <%@ import namespace="system.data" %>
    <%@ import namespace="system.data.ado" %>

    <script language="c#" runat="server">
    protected void page_load(object src, eventargs e)
    {
    string strconn;
    strconn = "provider=microsoft.jet.oledb.4.0;" +
    "data source=c://exceltest.xls;" +
    "extended properties=excel 8.0;";
    'you must use the $ after the object you reference in the spreadsheet
    adodatasetcommand mycommand = new adodatasetcommand("select * from [sheet1$]", strconn);

    dataset mydataset = new dataset();
    mycommand.filldataset(mydataset, "excelinfo");
    datagrid1.datasource = mydataset.tables["excelinfo"].defaultview;
    datagrid1.databind();
    }
    </script>
    <p><asp:label id=label1 runat="server">spreadsheet contents:</asp:label></p>
    <asp:datagrid id=datagrid1 runat="server"/>


    vb.net code
    ----------------------------------------------
    <%@ page language="vb" %>
    <%@ import namespace="system.data" %>
    <%@ import namespace="system.data.ado" %>

    <script language="vb" runat="server">
    sub page_load(sender as object, e as eventargs)
    dim mydataset as new dataset()

    'you can also use the excel odbc driver i believe - didn't try though
    dim strconn as string = "provider=microsoft.jet.oledb.4.0;" & _
    "data source=c:/exceltest.xls;" & _
    "extended properties=""excel 8.0;"""

    'you must use the $ after the object you reference in the spreadsheet
    dim myadodatasetcommand as new adodatasetcommand("select * from [sheet1$]", strconn)
    myadodatasetcommand.tablemappings.add("table", "exceltest")
    myadodatasetcommand.filldataset(mydataset)

    datagrid1.datasource = mydataset.tables(0).defaultview
    datagrid1.databind()
    end sub
    </script>
    <p><asp:label id=label1 runat="server">spreadsheet contents:</asp:label></p>
    <asp:datagrid id=datagrid1 runat="server"/>
    發(fā)表評(píng)論 共有條評(píng)論
    用戶名: 密碼:
    驗(yàn)證碼: 匿名發(fā)表
    主站蜘蛛池模板: 江川县| 渭南市| 赤水市| 左权县| 肥城市| 瑞安市| 德州市| 蛟河市| 晋江市| 郎溪县| 台中市| 方城县| 西充县| 德兴市| 宁安市| 北宁市| 海宁市| 六枝特区| 仁怀市| 阿城市| 九龙城区| 海口市| 泰和县| 石家庄市| 盐津县| 波密县| 吴忠市| 锦州市| 大余县| 广昌县| 浮山县| 巢湖市| 五常市| 崇明县| 都兰县| 汽车| 镇平县| 翁源县| 若羌县| 鹿邑县| 师宗县|