示例#1
0
 protected void ibtnExportPDFAppTableDoc_Click(object sender, ImageClickEventArgs e)
 {
     if (GridAC.Rows.Count > 0)
     {
         Response.ContentType = "application/pdf";
         Response.AddHeader("content-disposition",
                            "attachment;filename=MembershipAccount.pdf");
         Response.Cache.SetCacheability(HttpCacheability.NoCache);
         StringWriter   sw = new StringWriter();
         HtmlTextWriter hw = new HtmlTextWriter(sw);
         GridAC.AllowPaging = false;
         GridAC.DataSource  = GetDataSource();
         GridAC.DataBind();
         GridAC.RenderControl(hw);
         StringReader sr         = new StringReader(sw.ToString());
         Document     pdfDoc     = new Document(PageSize.A4, 10f, 10f, 10f, 0f);
         HTMLWorker   htmlparser = new HTMLWorker(pdfDoc);
         PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
         pdfDoc.Open();
         htmlparser.Parse(sr);
         pdfDoc.Close();
         Response.Write(pdfDoc);
         Response.End();
     }
 }
示例#2
0
 protected void ibtnExportExcelAppTableDoc_Click(object sender, ImageClickEventArgs e)
 {
     try
     {
         GridAC.AllowPaging = false;
         GridAC.DataSource  = GetDataSource();
         GridAC.DataBind();
         if (GridAC.Rows.Count > 0)
         {
             Response.Clear();
             Response.Buffer = true;
             Response.AddHeader("content-disposition",
                                "attachment;filename=AccountDDReport.xls");
             Response.Charset     = "";
             Response.ContentType = "application/vnd.ms-excel";
             StringWriter   sw = new StringWriter();
             HtmlTextWriter hw = new HtmlTextWriter(sw);
             GridAC.RenderControl(hw);
             string style = @"<style> .textmode { mso-number-format:\@; } </style>";
             Response.Write(style);
             Response.Output.Write(sw.ToString());
             Response.Flush();
             Response.End();
         }
     }
     catch (FormatException ex)
     {
     }
 }
示例#3
0
 protected void ibtnExportDocAppTableDoc_click(object sender, ImageClickEventArgs e)
 {
     if (GridAC.Rows.Count > 0)
     {
         Response.Clear();
         Response.Buffer = true;
         Response.AddHeader("content-disposition",
                            "attachment;filename=MembershipAccount.doc");
         Response.Charset     = "";
         Response.ContentType = "application/vnd.ms-word ";
         StringWriter   sw = new StringWriter();
         HtmlTextWriter hw = new HtmlTextWriter(sw);
         GridAC.AllowPaging = false;
         GridAC.DataSource  = GetDataSource();
         GridAC.DataBind();
         GridAC.RenderControl(hw);
         Response.Output.Write(sw.ToString());
         Response.Flush();
         Response.End();
     }
 }