c# - header not displaying after excel export -


image 1 image 2

after excel export header not displayed. here excel code:

private void exportgridview() {     string attachment = "attachment; filename=" + path.getfilename(request.physicalpath).substring(0, path.getfilename(request.physicalpath).length - 5) + "_" + enrdropdownlist.selecteditem + ".xls";     response.clearcontent();     mygridview.showheader = true;  /* code added show header in excel export on 05/05/2016  */      response.cache.setcacheability(httpcacheability.nocache);     response.addheader("content-disposition", attachment);     response.contenttype = "application/vnd.ms-excel";     stringwriter stw = new stringwriter();     htmltextwriter htextw = new htmltextwriter(stw);     string style = @"<style> .textmode { mso-number-format:\@; } </style>";     response.write(style);     string cellcount = mygridview.rows[0].cells.count.tostring();     string header = "<div><table style='font-weight:bold' width= '";     header += mygridview.width.tostring() + "'><tr><td align='center' colspan='";     header += cellcount + "'>texas tech university</td></tr>";     header += "<tr><td align='center' colspan='";     header += cellcount + "'>" + caption.text.toupper() + "</td></tr>";     header += "<tr><td align='center' colspan='";     header += cellcount + "'>department of institutional research</td></tr><tr><td align='center' colspan='";     header += cellcount + "'>(uncertified data)</td></tr><tr><td colspan='"; header += cellcount + "'></td></tr></table></div>"; //     response.output.write(header);     mygridview.databind();     mygridview.rendercontrol(htextw);     response.output.write(stw.tostring());     //mygridview.showheader = false; /* code added remove header after excel export on 05/05/2016 */     response.end(); } 

and here table:

     <asp:table cssclass = "center1" id="table1" runat="server"                          bordercolor ="black" width = "1505px" left = "-200px">                     <asp:tableheaderrow id="tableheaderrow1" runat="server">             <asp:tableheadercell  backcolor = "#cc0000" forecolor="#ffffff" width="40px" rowspan = "2">college</asp:tableheadercell>             <asp:tableheadercell backcolor = "#cc0000" forecolor="#ffffff" width="100px" rowspan = "2">dept</asp:tableheadercell>             <asp:tableheadercell backcolor = "#cc0000" forecolor="#ffffff" width="743px" rowspan = "2">major</asp:tableheadercell>             <asp:tableheadercell backcolor = "#cc0000" forecolor="#ffffff" width="480px"  columnspan = "6" >graduate</asp:tableheadercell>        <asp:tableheadercell backcolor = "#cc0000" forecolor="#ffffff" width="10px" columnspan = "5">law</asp:tableheadercell>        <asp:tableheadercell backcolor = "#cc0000" forecolor="#ffffff" width="795px" columnspan = "7">undergraduate</asp:tableheadercell>           <asp:tableheadercell  backcolor = "#cc0000" forecolor="#ffffff" width="105px" rowspan = "2">total</asp:tableheadercell>         </asp:tableheaderrow>         <asp:tablerow id="tablerow1" runat="server" backcolor = "#cc0000" forecolor="#ffffff">         <asp:tablecell width="5px">go</asp:tablecell>             <asp:tablecell width="45px">ng</asp:tablecell>             <asp:tablecell width="15px">sg</asp:tablecell>             <asp:tablecell width="110px">gm</asp:tablecell>             <asp:tablecell width="115px">gd</asp:tablecell>             <asp:tablecell width="80px">total</asp:tablecell>               <asp:tablecell width="80px">y1</asp:tablecell>             <asp:tablecell width="70px">y2</asp:tablecell>             <asp:tablecell width="85px">y3</asp:tablecell>             <asp:tablecell width="13px">sp</asp:tablecell>             <asp:tablecell width="45px">total</asp:tablecell>              <asp:tablecell width="116px">fr</asp:tablecell>             <asp:tablecell width="106px">so</asp:tablecell>             <asp:tablecell width="116px">jr</asp:tablecell>             <asp:tablecell width="106px">sr</asp:tablecell>             <asp:tablecell width="66px">sd</asp:tablecell>             <asp:tablecell width="25px">su</asp:tablecell>             <asp:tablecell width="110px">total</asp:tablecell>         </asp:tablerow>     </asp:table> 

you can refer link : http://techdata.irs.ttu.edu/factbook/enrollment/enrmajorclass.aspx


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -