CodeToday.NET » Microsoft .NET Developer Forum » ASP.NET & Expression Web » Export data into Excel
อยากทราบวิธีการนำข้อมูลใน gridview/DTables ไปเก็บเป็น file excel
ไม่ทราบว่าทำยังไง ใครทราบช่วยตอบด้วยน่ะค่ะ
ขอบคุณล่วงหน้าค่ะ
ขอเป็น VB น่ะค่ะจะดีมากค่ะ
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()
Main Forum 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/2008Copyright © 2003-2008 Yet Another Forum.net. All rights reserved.