.NET Logo
Welcome Guest Search | Active Topics | Members | Log In | Register

Export data into Excel Options · View
littleGirl
Posted: Thursday, September 11, 2008 3:40:27 PM
Rank: มือสมัครเล่น
Groups: Member

Joined: 4/7/2008
Posts: 24
Location: BKK

อยากทราบวิธีการนำข้อมูลใน gridview/DTables ไปเก็บเป็น file excel

ไม่ทราบว่าทำยังไง ใครทราบช่วยตอบด้วยน่ะค่ะ

ขอบคุณล่วงหน้าค่ะ

ขอเป็น  VB น่ะค่ะจะดีมากค่ะ

ZeedZard
Posted: Thursday, September 11, 2008 4:35:59 PM
Rank: มือพระกาฬ
Groups: Member

Joined: 6/12/2008
Posts: 50
Location: King Mongkut's Institute of Technology Ladkrabang
        Dim curForm As New HtmlForm
        Dim sw As New System.IO.StringWriter()
        Dim HtW As New System.Web.UI.HtmlTextWriter(sw)

        Response.ClearContent()
        Response.AddHeader("Content-Disposition", "attachment; filename=" & XLSFile) 'กำหนดชื่อไฟล์
        Response.ContentType = "application/ms-excel"

        Response.BufferOutput = True
        Response.ContentEncoding = System.Text.Encoding.UTF8
        Response.Charset = "UTF-8"

        dim grvReport as new gridview
        grvReport.datasource = dTable 'datatable ที่ต้องการใส่ให้ grid
       
        curForm.Controls.Add(grvReport)
        Me.Controls.Add(curForm)
        curForm.RenderControl(HtW)
        Me.EnableViewState = False
        Response.Write(sw.ToString())
        Response.End()
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

YAFVision Theme Created by Jaben Cargman (Tiny Gecko)
Powered by Yet Another Forum.net version 1.9.1.8 (NET v2.0) - 3/29/2008
Copyright © 2003-2008 Yet Another Forum.net. All rights reserved.


Sponsored by