dhoni kholi

dhoni kholi

  • 1.9k
  • 198
  • 21.3k

How to Export in Excel

Dec 30 2019 11:41 PM
This is my Code 
 
  1. <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">  
  2. <div id="page-wrapper" >  
  3.          <div class="col-md-12">  
  4.   <!-- Form Elements -->  
  5.          <div class="panel panel-info">  
  6.          <div class="panel-heading">  
  7.                <h3 style="text-shadow: 2px 2px #79aed8;">Barcode List </h3>    
  8.           </div>  
  9.           <div class="panel-body">  
  10.           <div id="Barcode">  
  11.            <h1 align="center"   
  12.                   style="text-decoration: underline; font-size: x-large; font-weight: bold">Barcode</h1>  
  13.   
  14.               <asp:Panel ID="Panel1" runat="server">  
  15.                   <asp:Label ID="lblPname" runat="server" Text="" Font-Bold="True"></asp:Label>   
  16.                   <br />  
  17.                 <%--  <asp:PlaceHolder ID="phBarcode" runat="server" Visible="true"></asp:PlaceHolder>  
  18.                   </asp:Panel>--%>  
  19.                  <asp:Image ID="Image1" runat="server" Height="70px" Width="250px" />  
  20.               <div class="table-responsive";>  
  21.                  <table class="table">  
  22.                     <tbody>  
  23.                     <tr>  
  24.                     <td>  
  25.                         <asp:Button ID="btnPPdf" runat="server" Text="Print" CssClass="btn-info"   
  26.                             Width="100px"/>  
  27.                       
  28.                          <asp:Button ID="btnExcel" runat="server" Text="Excel" CssClass="btn-success"   
  29.                             Width="100px" onclick="btnExcel_Click"  />  
  30.                       
  31.                          <asp:Button ID="btnBack" runat="server" Text="Back" CssClass="btn-danger"   
  32.                             Height="35px" Width="100px" />  
  33.                     </td>  
  34.                     </tr>  
  35.                     </tbody>   
  36.                  </table>  
  37.              </div>  
  38.           </div>  
  39.   
  40.            </div>  
  41.          </div>  
  42.       </div>  
  43.    </div>  
  44. </asp:Content>  
I want export to Excel in Content of Inside the Panel  
 
I use this Code this  
 
  1. protected void btnExcel_Click(object sender, EventArgs e)  
  2.       {  
  3.           Response.Clear();  
  4.           Response.AddHeader("content-disposition""attachment;filename=FileName.xls");  
  5.           Response.Charset = "";  
  6.           Response.ContentType = "application/vnd.xls";  
  7.           System.IO.StringWriter stringWrite = new System.IO.StringWriter();  
  8.           System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);  
  9.           Panel1.RenderControl(htmlWrite);  
  10.           Response.Write(stringWrite.ToString());  
  11.           Response.End();  
  12.       }  
My output is  
 
 
 
I want that Lable and Image 

Answers (8)