久久国产成人av_抖音国产毛片_a片网站免费观看_A片无码播放手机在线观看,色五月在线观看,亚洲精品m在线观看,女人自慰的免费网址,悠悠在线观看精品视频,一级日本片免费的,亚洲精品久,国产精品成人久久久久久久

分享

C#(asp.net)實(shí)現(xiàn)數(shù)據(jù)導(dǎo)出Excel表詳細(xì)代碼

 jsjjtylz 2014-02-25

本例介紹的用C#(asp.net)實(shí)現(xiàn)數(shù)據(jù)導(dǎo)出Excel詳細(xì)代碼的方法,,會(huì)輸出標(biāo)準(zhǔn)的Excel格式文件,,非常穩(wěn)定,不會(huì)死鎖Excel進(jìn)程,,支持中文文件名,,支持表頭導(dǎo)出,,支持大多數(shù)數(shù)據(jù)庫(kù)導(dǎo)入。

C#(asp.net)數(shù)據(jù)導(dǎo)出Excel實(shí)現(xiàn)算法:利用Excel組件將DataGrid控件內(nèi)容生成Excel臨時(shí)文件,,并存放在服務(wù)器上,,然后用Response方法將生成的Excel文件下載到客戶端然后再將生成的臨時(shí)文件刪除。

25億CMS系統(tǒng)v2.9實(shí)現(xiàn)此功能,,大家可以25億CMS系統(tǒng)后臺(tái)查看并研究,。

C#(asp.net)數(shù)據(jù)導(dǎo)出Excel具體步驟:
1,在項(xiàng)目中引用Excel組件(Interop.Excel.dll),如需此組件,,可以到技術(shù)社區(qū)(http://bbs.)索取,,25億官方技術(shù)部會(huì)提供。
2,aspx頁(yè)面代碼:
  <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" AllowPaging="True" CellPadding="8"
Width="690px" onpageindexchanging="gridview1_PageIndexChanging" PageSize="15"  >
        <FooterStyle BackColor="White" ForeColor="#000066" />
        <RowStyle ForeColor="#000066" />
         
        <Columns>
           <asp:TemplateField HeaderText="用戶ID"  >
    <ItemTemplate>
    <asp:Label runat="server" ID="name" Text='<%#DataBinder.Eval(Container.DataItem,"UserInfoId")%>'> </asp:Label>
    </ItemTemplate>
    </asp:TemplateField>
     <asp:TemplateField HeaderText="用戶名"  >
    <ItemTemplate>
    <asp:Label runat="server" ID="na" Text='<%#DataBinder.Eval(Container.DataItem,"UserName")%>'> </asp:Label>
    </ItemTemplate>
    </asp:TemplateField>
        <asp:TemplateField HeaderText="注冊(cè)時(shí)間"  >
    <ItemTemplate>
    <asp:Label runat="server" ID="na" Text='<%#DataBinder.Eval(Container.DataItem,"AddTime")%>'> </asp:Label>
    </ItemTemplate>
     </asp:TemplateField>
            <asp:TemplateField HeaderText="登錄次數(shù)"  >
    <ItemTemplate>
    <asp:Label runat="server" ID="na" Text='<%#DataBinder.Eval(Container.DataItem,"LoginNum")%>'> </asp:Label>
    </ItemTemplate>
    </asp:TemplateField>
                <asp:TemplateField HeaderText="最后登錄時(shí)間"  >
    <ItemTemplate>
    <asp:Label runat="server" ID="na" Text='<%#DataBinder.Eval(Container.DataItem,"EndTime")%>'> </asp:Label>
    </ItemTemplate>
    </asp:TemplateField>
    
    </Columns>
     <PagerSettings FirstPageText="首頁(yè)" LastPageText="尾頁(yè)"
            NextPageText="下一頁(yè)" PreviousPageText="上一頁(yè)" Mode="NextPreviousFirstLast" />
      
    </asp:GridView>
3,cs代碼:
    public void DataSourse()
    {
            //GridView數(shù)據(jù)綁定
        GridView1.DataSource = bllintable.GetModds(9, Remark, this.pbComment.CurrentPage - 1, this.pbComment.PageSize, Language);
        GridView1.DataBind();
    }
    public override void VerifyRenderingInServerForm(Control control)
    {

    }

    private void Export(string FileType, string FileName)
    {
        Response.Charset = "GB2312";
        Response.ContentEncoding = System.Text.Encoding.UTF7;
        Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, Encoding.UTF8).ToString());
        Response.ContentType = FileType;
        this.EnableViewState = false;
        StringWriter tw = new StringWriter();
        HtmlTextWriter hell = new HtmlTextWriter(tw);
        GridView1.AllowPaging = false;
        DataSourse();
        GridView1.RenderControl(hell);
        Response.Write(tw.ToString());
        Response.End();
        GridView1.AllowPaging = true;
        DataSourse();


    }
直接把上述代碼復(fù)制到頁(yè)面中,,修改GridView綁定參數(shù)既可以運(yùn)行,如有疑問(wèn),,可以官方技術(shù)社區(qū)(http://bbs.)提問(wèn)。

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,,所有內(nèi)容均由用戶發(fā)布,,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式,、誘導(dǎo)購(gòu)買等信息,,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,,請(qǐng)點(diǎn)擊一鍵舉報(bào),。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多