While downloading .CSV it saves as an excel file.

K

ksskumar2000

Hi Friends,

What I want:
If the user click a hyperlink, I have to download a .CSV file into the
users machine.

What I tried:
<asp:HyperLink id=HyperLink1 runat="server"
NavigateUrl="Sample.csv">download file.</asp:HyperLink>

The Problem:
While clicking the link the file downloading as an Excel file not as a
..CSV
Even in the "File Download: Do you want to open or save this file?"
dialog window shows like,
Name: Sample.xls
Type: Microsoft Excel Worksheet

My Question:
What I have to do to download the file as it is (.CSV)?

thanks in advance,
Kumar.
 
S

shahkalpesh

Hi,

Change the contenttype property of Response to "text/csv"
This will make the text written to browser in CSV format. However, this
will not throw the "Save As" dialog to the user

The browser is forcing you to save the csv using excel. Because the csv
extension is linked with Excel

Kalpesh
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top