Пример #1
0
        protected void btnExport_Click(object sender, EventArgs e)
        {
            FullCardInfoHelper helper    = new FullCardInfoHelper();
            List <ExportData>  lstExport = helper.GetExportData();

            if (lstExport.Count > 0)
            {
                Response.Clear();
                Response.Buffer = true;
                Response.AddHeader("content-disposition", "attachment;filename=DataCleaningExport.xls");
                Response.ContentType     = "application/ms-excel";
                Response.ContentEncoding = System.Text.Encoding.Unicode;
                Response.BinaryWrite(System.Text.Encoding.Unicode.GetPreamble());
                using (StringWriter sw = new StringWriter())
                {
                    HtmlTextWriter hw = new HtmlTextWriter(sw);
                    GridView1.DataSource = lstExport;
                    GridView1.DataBind();
                    GridView1.RenderControl(hw);
                    //style to format numbers to string
                    string style = @"<style> .textmode { } </style>";
                    Response.Write(style);
                    Response.Output.Write(sw.ToString());
                    Response.Flush();
                    Response.End();
                }
            }
        }
Пример #2
0
        private void GetProcessData(string step)
        {
            FullCardInfoHelper dataHelper = new FullCardInfoHelper();
            Login login = (Login)Session[DataCleaningConstant.LoginInfoSession];
            List <FullCardInfo> lstData = dataHelper.GetProcessData(login.UserLogin.user_name, step);
            var jsonSerialiser          = new JavaScriptSerializer();
            var json = jsonSerialiser.Serialize(lstData);

            Response.Write(json);
            Response.End();
        }