Click here to Skip to main content
15,887,214 members
Home / Discussions / C#
   

C#

 
AnswerRe: calculating grades with files and arrays Pin
PIEBALDconsult10-Apr-13 19:05
mvePIEBALDconsult10-Apr-13 19:05 
AnswerRe: calculating grades with files and arrays Pin
Abhinav S10-Apr-13 19:07
Abhinav S10-Apr-13 19:07 
GeneralRe: calculating grades with files and arrays Pin
Magda634710-Apr-13 19:38
Magda634710-Apr-13 19:38 
AnswerRe: calculating grades with files and arrays Pin
Abhinav S10-Apr-13 19:49
Abhinav S10-Apr-13 19:49 
AnswerRe: calculating grades with files and arrays Pin
V.11-Apr-13 19:57
professionalV.11-Apr-13 19:57 
Questionsmartcard application Pin
prasannakumarV10-Apr-13 18:21
prasannakumarV10-Apr-13 18:21 
AnswerRe: smartcard application Pin
Abhinav S10-Apr-13 19:44
Abhinav S10-Apr-13 19:44 
Questionfirst row blank when export from gridview to excel with master pages included project Pin
Dhyanga10-Apr-13 10:56
Dhyanga10-Apr-13 10:56 
Hi,

I am trying to export gridview data to excel. It is working fine except the first row in the excel is blank.

The code i used for the excel is shown below:
C#
HttpContext.Current.Response.Clear(); //clear anything in io buffer
           Response.ClearContent();
           HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=GrpFile.xls");
           HttpContext.Current.Response.Charset = "";
           HttpContext.Current.Response.ContentType = "application/vnd.ms-excel";
           StringWriter sw = new StringWriter();
           HtmlTextWriter hw = new HtmlTextWriter(sw);
           HtmlForm frm = new HtmlForm();
           gvCampGrp.Parent.Controls.Add(frm);
           frm.Attributes["runat"] = "server";
           frm.Controls.Add(gvCampGrp);
           frm.RenderControl(hw);
           HttpContext.Current.Response.Write(sw.ToString());
           HttpContext.Current.Response.End();


I also included the following code.
C#
public override void VerifyRenderingInServerForm(Control control)
     {
         /* Confirms that an HtmlForm control is rendered for the specified ASP.NET
            server control at run time. */
         return;
     }


How to export data to excel without making its first row empty?
Please help.
Dhyanga

AnswerRe: first row blank when export from gridview to excel with master pages included project Pin
Dhyanga11-Apr-13 4:03
Dhyanga11-Apr-13 4:03 
Questionmaking a desktop lights app Pin
Johnny English10-Apr-13 4:44
Johnny English10-Apr-13 4:44 
AnswerRe: making a desktop lights app Pin
Eddy Vluggen10-Apr-13 5:06
professionalEddy Vluggen10-Apr-13 5:06 
GeneralRe: making a desktop lights app Pin
Johnny English10-Apr-13 5:18
Johnny English10-Apr-13 5:18 
AnswerRe: making a desktop lights app Pin
Eddy Vluggen10-Apr-13 6:52
professionalEddy Vluggen10-Apr-13 6:52 
GeneralRe: making a desktop lights app Pin
Johnny English10-Apr-13 10:30
Johnny English10-Apr-13 10:30 
GeneralRe: making a desktop lights app Pin
Eddy Vluggen10-Apr-13 11:08
professionalEddy Vluggen10-Apr-13 11:08 
GeneralRe: making a desktop lights app Pin
Johnny English10-Apr-13 20:37
Johnny English10-Apr-13 20:37 
AnswerRe: making a desktop lights app Pin
Clifford Nelson10-Apr-13 11:04
Clifford Nelson10-Apr-13 11:04 
AnswerRe: making a desktop lights app Pin
Abhinav S10-Apr-13 19:39
Abhinav S10-Apr-13 19:39 
GeneralRe: making a desktop lights app Pin
Johnny English10-Apr-13 20:39
Johnny English10-Apr-13 20:39 
QuestionMessage Closed Pin
10-Apr-13 3:36
sisadosizdah10-Apr-13 3:36 
AnswerRe: Fuzzy Logic Pin
Dave Kreskowiak10-Apr-13 3:41
mveDave Kreskowiak10-Apr-13 3:41 
JokeRe: Fuzzy Logic Pin
fjdiewornncalwe10-Apr-13 4:28
professionalfjdiewornncalwe10-Apr-13 4:28 
GeneralRe: Fuzzy Logic Pin
Dave Kreskowiak10-Apr-13 7:28
mveDave Kreskowiak10-Apr-13 7:28 
AnswerRe: Fuzzy Logic Pin
Clifford Nelson10-Apr-13 11:05
Clifford Nelson10-Apr-13 11:05 
AnswerMy vote of 1 Pin
Eddy Vluggen10-Apr-13 5:07
professionalEddy Vluggen10-Apr-13 5:07 

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.