Tutorials
Resources
Forum
Reviews
Communities
Interview
Jobs
Projects
Training
Your
Ad
Here
Silverlight Games
|
Mentor
|
Code Converter
|
Articles
|
Code Factory
|
Computer Jokes
|
Members
|
Peer Appraisal
|
IT Companies
|
Bookmarks
|
Polls
|
Revenue Sharing
|
Lobby
|
Gift Shop
|
Prizes & Awards
My Profile
Sign In
Register
AdSense Revenue
Active Members
Today
Nikhil Gaur
(70)
Nadheera V
(30)
Shameer
(18)
Last 7 Days
Nikhil Gaur
(621)
Anil Kumar ...
(582)
Abhisek Panda
(445)
more...
Resources
»
Code Snippets
»
C# Syntax
»
Stored Files are Retrived using this code
Posted Date: 22 May 2008
Resource Type:
Code Snippets
Category:
C# Syntax
Author:
Ashok Kandasamy
Member Level:
Diamond
Rating:
Points
: 10
Hi,
This code is used to retrive the file which is already stored in the server using fileupload control.
[CODE}
protected void btnExcelTemplate_Click(object sender, EventArgs e)
{
// string xlsPath = Request.PhysicalApplicationPath;
try
{
string xlsPath = Request.PhysicalApplicationPath + @"\Template\Training";
string filePath = xlsPath + @"\TrainingHistory.xls";
if (File.Exists(filePath))
{
FileInfo fi = new FileInfo(filePath);
Response.Clear();
Response.ClearHeaders();
Response.Buffer = false;
Response.AppendHeader("Content-Disposition", "attachment;filename = " + System.Web.HttpUtility.UrlEncode(System.Text.Encoding.UTF8.GetBytes("TrainingHistory.xls")));
Response.AppendHeader("Content-Length", fi.Length.ToString());
Response.ContentType = "application/ms-excel";
Response.WriteFile(filePath);
Response.Flush();
Response.End();
}
}
catch (Exception exp)
{
lblMessage.Text = exp.Message;
}
}
Responses
Author:
Balamurali Balaji
22 May 2008
Member Level:
Diamond
Points
: 2
Hi,
Your code opens excel to show the specified file. It does not show excel data on a web page.
How do we display excel data on the page?
Goodluck
Feedbacks
Popular Tags
What are tags ?
Search Tags
Sign In
to add tags.
(No tags found.)
Post Feedback
This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must
Sign In
to post a response.
Next Resource:
Programmatically Compile WebSite
Previous Resource:
How to Subtract Dates
Return to Discussion Resource Index
Post New Resource
Category:
C# Syntax
Post resources and
earn money
!
Related Resources
Programmatically Compile WebSite
Re-Usable Class for Sending Emails using ASP.Net 2.0
Piant event of Datagrid view to merge the Header
How to find the value using regular expression
How to write a simple function to import the data into excel sheet
Change the Filename Extension using Path class
dotNet Slackers
About Us
Contact Us
Privacy Policy
Terms Of Use