|
-
March 18th, 2010, 05:10 AM
#1
Export to .csv problem
Hi,
Export to XXX.csv through asp.net application is working for most of us. But for 1 user it is not working properly. Instead of the file name XXX.csv, the download window shows ABC.aspx and the type of the file is recognized as unknown.
I am using the below code to export the data from the grid using a link button click...
File Name:- ABC.aspx.cs
private void lbtExport_Click(object sender, System.EventArgs e)
{
if(dgData.Items.Count>0)
ExportToCSV();
}
#endregion
#region Export to CSV
private void ExportToCSV()
{
string strData = Export();
byte[] data = System.Text.ASCIIEncoding.ASCII.GetBytes(strData);
Response.Clear();
Response.AddHeader("Content-Type", "application/Excel");
Response.AddHeader("Content-Disposition", "inline;filename=XXX.csv");
Response.BinaryWrite(data);
Response.End();
}
#endregion
I tried the below steps already...
1. Delete the IE Browser cache
2. Close & re-open the IE browser
3. Restart the client PC
...even after I tried the above, I can not able to fix the issue.
If any of you guys know how to fix the issue, please help me...
Thanks
Priya
-
March 18th, 2010, 09:49 AM
#2
Re: Export to .csv problem
I don't know if it makes any difference, but Content-type should be text/plain. A .CSV file can be opened with Excel, but is not by definition also the same type.
Also try setting the content type as follow
Code:
Response.ContentType = "text/plain";
-
March 22nd, 2010, 08:30 PM
#3
Re: Export to .csv problem
Hi danny,
I will replace with your code & try.
But I am bit concerned about the thing that the same (existing) code is working for other users. Only for this user it not...
So I am curious to know whether it is due to any IE browser settings...Or any other client pc issue.
If you have any ans...please help me to understand...
Note:
I generated the csv file from my pc... Copied it to the users pc... & tried opening it...
There is no problem in opening the .csv file from the clients pc.
Only it is not accepting from the application.
Thanks
Priya
-
April 15th, 2010, 02:52 AM
#4
Re: Export to .csv problem
Hi,
The export to .csv file is not working for one of the user.
For other users it is working fine.
=> Client PC specific.
Is ther any way to solve the issue without changing the program?
If any one know the solution, please help me on this.
Thanks
Priya
-
April 15th, 2010, 03:30 AM
#5
Re: Export to .csv problem
Hi.
Have you tried changing the content type? I don't think you should change the program. You need to know and understand why it is not working for this particular user. Do you have access to the client workstation? Or can you get the specifications (OS version, browser version and applications installed)?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|