codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Export to excel  eshwar_gp at 07:16 on Thursday, January 06, 2005
 

Hi,
I have to export dyanmic date from grid/dataset to excel sheet with filelds in C# with .Net. Datbase is sqlserver 2000

I donot know how to do?
please guide me.


Regards,
eshwar_gp

  Re: Export to excel  Granby at 22:27 on Wednesday, January 26, 2005
 

Here is some vb.net code that works

<%@ Import Namespace="System.IO" %>

Sub Click_Excel(S as Object,E as EventArgs)
Response.Cache.SetExpires(DateTime.Now.AddSeconds(1))
Response.ContentType = "application/vnd.ms-excel"
Response.Charset = ""
EnableViewState = false
Dim tw as new StringWriter()
Dim hw as new HtmlTextWriter(tw)
GridOpen.RenderControl(hw)

dim fName as String
Fname = "TTCR" & format(Now,"HH_MM") & "/forum/.xls"

'Fname is the default filename given to the user in the save as box

Response.AppendHeader("content-disposition","attachment;filename=" & Fname )
Response.Write(tw.ToString())
Response.End()

End Sub

Good Luck

  Re: Export to excel  k_satyaraj@rediffmail.com at 09:29 on Monday, January 31, 2005
 

use the following line to print the data in excel

Response.ContentType="application/vnd.ms-excel";

place the above line where ever u want and execute









CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
//








Recent Forum Threads
•  Java code for Insert picture on the table in spreadsheet
•  Re: Problem with concatenation
•  how to genrates the crystal report by sending a id at runtime
•  help me
•  pls help me with this..
•  Re: Security - Code verify
•  Job @ EarlySail
•  Job @ EarlySail (perl)
•  IPC problem


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2007