Click here to Skip to main content
15,915,745 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionIssue with modalpopup on master page. Pin
shock58922-Sep-11 19:23
shock58922-Sep-11 19:23 
AnswerRe: Issue with modalpopup on master page. Pin
Parwej Ahamad22-Sep-11 23:24
professionalParwej Ahamad22-Sep-11 23:24 
AnswerRe: Issue with modalpopup on master page. Pin
jagdish Bhandari23-Sep-11 1:16
jagdish Bhandari23-Sep-11 1:16 
QuestionExport dataset to Excel Pin
countmein22-Sep-11 12:10
countmein22-Sep-11 12:10 
Hi,

When I tried to implement the code from this forum to display data in the excel from a webpage, I am getting weird results. I am wondering if you could direct me to correct the problem? I thank you for your help.

The code is :

HttpResponse response = HttpContext.Current.Response;
response.Clear();
response.Charset = "";
//MAKE THE CONTENT TYPE TO EXCEL FORMAT.
response.ContentType = "application/vnd.ms-excel";
response.AddHeader("Content-Disposition", "attachment;filename=\"" + filename + ".xls\"");
// CREATE A STRING WRITER.
using (StringWriter sw = new StringWriter())
{
using (HtmlTextWriter htw = new HtmlTextWriter(sw))
{
// INSTANTIATE A DATAGRID.
GridView dg = new GridView();
dg.DataSource = ds.Tables[0];
dg.DataBind();
dg.RenderControl(htw);
//STYLE TO FORMAT NUMBERS TO STRING.
string style1 = @" .textmode { mso-number-format:\@; } ";
response.Write(sw.ToString());
response.Write(style1);
//response.Flush();
HttpContext.Current.ApplicationInstance.CompleteRequest();
}
}
}
catch (Exception ex)
{
throw ex;
}
}

ds:is the dataset
and filename is the name of the filename.

However, the file contains data as below:
"
"
MonthYearUSERIDApplicationNumOfReturns"
"
08/2011userid12010"
"
08/2011userid22010"
"
08/2011userid32009"
"
08/2011userid42010"
"
"
.textmode { mso-number-format:\@; }




<title>
" Untitled Page"














I am wondering what wrong with my code. Any help is greatly appreciated. Thank you.
AnswerRe: Export dataset to Excel Pin
uspatel23-Sep-11 2:47
professionaluspatel23-Sep-11 2:47 
GeneralRe: Export dataset to Excel Pin
countmein23-Sep-11 4:01
countmein23-Sep-11 4:01 
QuestionASP.NET MVC3 Pin
eddieangel22-Sep-11 11:03
eddieangel22-Sep-11 11:03 
QuestionC#.asp.net 2010 development plan Pin
Member 821751722-Sep-11 6:03
Member 821751722-Sep-11 6:03 
QuestionWant a solution for this problem Pin
Dinesh Denny22-Sep-11 3:01
Dinesh Denny22-Sep-11 3:01 
AnswerRe: Want a solution for this problem Pin
m@dhu22-Sep-11 3:48
m@dhu22-Sep-11 3:48 
AnswerRe: Want a solution for this problem Pin
Shah Rizal22-Sep-11 16:20
Shah Rizal22-Sep-11 16:20 
QuestionGet frame on another page Pin
Mugdha_Aditya22-Sep-11 2:51
Mugdha_Aditya22-Sep-11 2:51 
QuestionNeed to access physical file in iSeries by using asp.net Pin
Member 322226421-Sep-11 15:02
Member 322226421-Sep-11 15:02 
QuestionQuestion on entity class in the layer Pin
DotNetXenon21-Sep-11 9:07
DotNetXenon21-Sep-11 9:07 
AnswerRe: Question on entity class in the layer Pin
Pravin Patil, Mumbai21-Sep-11 18:53
Pravin Patil, Mumbai21-Sep-11 18:53 
GeneralRe: Question on entity class in the layer Pin
DotNetXenon22-Sep-11 5:52
DotNetXenon22-Sep-11 5:52 
GeneralRe: Question on entity class in the layer Pin
Pravin Patil, Mumbai23-Sep-11 7:10
Pravin Patil, Mumbai23-Sep-11 7:10 
GeneralRe: Question on entity class in the layer Pin
DotNetXenon23-Sep-11 8:04
DotNetXenon23-Sep-11 8:04 
GeneralRe: Question on entity class in the layer Pin
Pravin Patil, Mumbai23-Sep-11 19:36
Pravin Patil, Mumbai23-Sep-11 19:36 
Questioncreate user Pin
kunal Singh Rajput20-Sep-11 19:44
kunal Singh Rajput20-Sep-11 19:44 
AnswerRe: create user Pin
Blue_Boy20-Sep-11 21:15
Blue_Boy20-Sep-11 21:15 
AnswerRe: create user Pin
uspatel21-Sep-11 2:09
professionaluspatel21-Sep-11 2:09 
AnswerRe: create user Pin
Dalek Dave21-Sep-11 22:38
professionalDalek Dave21-Sep-11 22:38 
Question2010 C# asp.net designer Pin
classy_dog20-Sep-11 3:39
classy_dog20-Sep-11 3:39 
AnswerRe: 2010 C# asp.net designer Pin
Morgs Morgan20-Sep-11 5:18
Morgs Morgan20-Sep-11 5:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.