Riddhi Valecha

Riddhi Valecha

  • 636
  • 3.2k
  • 342k

Export To Word - Panel and placeholder - IMP

Jun 12 2018 11:09 AM
Dear Team,
 
I need help in exporting an entire Panel () to word document.
 
My ASPX Design is -
  1. <body>  
  2. <asp:Panel id="panel2" runat="server" width="100%">  
  3. <table width="1024px">  
  4. <tr>  
  5. <td>  
  6. <asp:Gridview id="grdData" runat="server"> </asp:GridView>  
  7. td>  
  8. tr>  
  9. <tr>  
  10. <td>  
  11. <asp:Placeholder id="ph1" runat="server"></asp:Placeholder>  
  12. td>  
  13. </tr>  
  14. <tr>  
  15. <td>  
  16. <asp:Gridview id="grdDataAdmin" runat="server"> </asp:GridView>  
  17. </td>  
  18. </tr>  
  19. </table>  
  20. </asp:Panel>  
  21. </body>  
By Button Code -
  1. protected void Export(object sender, EventArgs e)  
  2. {  
  3. Response.Clear();  
  4. Response.Buffer = true;  
  5. Response.ContentType = "application/vnd.word";  
  6. Response.ContentEncoding = System.Text.Encoding.UTF8;  
  7. Response.AddHeader("Content-Disposition""attachment;filename=History.doc");  
  8. Response.Charset = "";  
  9. EnableViewState = false;  
  10. Table table = new Table();  
  11. TableRow row = new TableRow();  
  12. row.Cells.Add(new TableCell());  
  13. row.Cells[0].Controls.Add(panel2);  
  14. table.Rows.Add(row);  
  15. System.IO.StringWriter oStringWriter = new System.IO.StringWriter();  
  16. System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);  
  17. table.RenderControl(oHtmlTextWriter);  
  18. Response.Write(oStringWriter.ToString());  
  19. Response.End();  
  20. }
Issue -
I am loading the placeholder on Page Load Event.
Entire Panel is exported , but not the placeholder.
 
How do I do this?
 
Please help...as this is a bit urgent... 

Answers (6)