Example #1
0
    protected void ibtnExportExcelAppTableDoc_Click(object sender, ImageClickEventArgs e)
    {
        GridDuplicacy.AllowPaging = false;
        GridDuplicacy.DataSource  = function();
        GridDuplicacy.DataBind();
        if (GridDuplicacy.Rows.Count > 0)
        {
            GridDuplicacy.Columns[7].Visible = false;
            GridDuplicacy.Columns[8].Visible = false;
            Response.Clear();
            Response.Buffer = true;
            Response.AddHeader("content-disposition",
                               "attachment;filename=Subscription.xls");
            Response.Charset     = "";
            Response.ContentType = "application/vnd.ms-excel";
            StringWriter   sw = new StringWriter();
            HtmlTextWriter hw = new HtmlTextWriter(sw);

            GridDuplicacy.RenderControl(hw);
            string style = @"<style> .textmode { mso-number-format:\@; } </style>";
            Response.Write(style);
            Response.Output.Write(sw.ToString());
            Response.Flush();
            Response.End();
        }
    }
Example #2
0
    protected void ibtnExportPDFAppTableDoc_Click(object sender, ImageClickEventArgs e)
    {
        GridDuplicacy.AllowPaging = false;
        GridDuplicacy.DataSource  = function();
        GridDuplicacy.DataBind();
        if (GridDuplicacy.Rows.Count > 0)
        {
            GridDuplicacy.Columns[7].Visible = false;
            GridDuplicacy.Columns[8].Visible = false;
            Response.ContentType             = "application/pdf";
            Response.AddHeader("content-disposition",
                               "attachment;filename=Subscription.pdf");
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            StringWriter   sw = new StringWriter();
            HtmlTextWriter hw = new HtmlTextWriter(sw);

            GridDuplicacy.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();
        }
    }
Example #3
0
 protected void ibtnExportDocAppTableDoc_click(object sender, ImageClickEventArgs e)
 {
     GridDuplicacy.AllowPaging = false;
     GridDuplicacy.DataSource  = fillgrid();
     GridDuplicacy.DataBind();
     if (GridDuplicacy.Rows.Count > 0)
     {
         GridDuplicacy.Columns[0].Visible = false;
         Response.Clear();
         Response.Buffer = true;
         Response.AddHeader("content-disposition",
                            "attachment;filename=Inspection.doc");
         Response.Charset     = "";
         Response.ContentType = "application/vnd.ms-word ";
         StringWriter   sw = new StringWriter();
         HtmlTextWriter hw = new HtmlTextWriter(sw);
         GridDuplicacy.RenderControl(hw);
         Response.Output.Write(sw.ToString());
         Response.Flush();
         Response.End();
     }
 }