How to open a text file and convert it to excel at the same time ,..

There are lots of ways of doing this ,.. but this is perhaps the eaciest (c:

public static void Write()

HttpResponse response =HttpContext.Current.Response;

// make sure nothing is in response stream
response.Charset =

// set MIME type to be Excel file.
response.ContentType ="application/";
"Content-Disposition", "attachment; filename=\"MyExcel_" + DateTime.Now.ToString() + "\".xls");

// Send the data. Tab delimited, with newlines.
System.IO.StreamReader reader = new System.IO.StreamReader(HttpContext.Current.Request.MapPath("~/Mytext.txt"));


// Close response stream.


prettey cool if i may say so ,.. (c:


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: