protected void btnExport_Click(object sender, EventArgs e)
        {
            string unityValue = selectedValue.Value;
            string kpiName = string.IsNullOrWhiteSpace(drpTags.SelectedValue) ? null : drpTags.SelectedValue;

            string beginTime = txtBeginTime.Value;
            string endTime = txtEndTime.Value;
            int totalCount = 0;

            List<KPI_OverLimitRecordEntity> overLimitRecordList = null;
            if (unityValue == "U01" || string.IsNullOrWhiteSpace(unityValue)) {

                overLimitRecordList = overLimitRecordDal.GetOverLimitRecordEntityList(Convert.ToDateTime(beginTime),
                    Convert.ToDateTime(endTime), 1, int.MaxValue, out totalCount);
            }
            else {
                overLimitRecordList = overLimitRecordDal.SearchOverLimitRecord(Pager.CurrentPageIndex, Pager.PageSize, kpiName, unityValue, beginTime, endTime, true, ref totalCount);

            }
            overLimitRecordList = ConverterHelper.ConverterItem(overLimitRecordList);
            gvValue.DataSource = overLimitRecordList;
            gvValue.DataBind();
            if (gvValue.Rows.Count > 0) {
                DocExport docEexport = new DocExport();

                docEexport.Dt = GridViewHelper.GridView2DataTable(gvValue);

                docEexport.Export("SIS超限统计报表");
            }
        }
        // <summary>
        /// 导出到EXCEL
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnExport_Click(object sender, EventArgs e)
        {
            if (gvScore.Rows.Count > 0)
            {
                DocExport docEexport = new DocExport();

                docEexport.Dt = GridViewHelper.GridView2DataTable(gvScore);

                docEexport.Export("SIS系统实时指标分析报表");
            }

            return;
        }
        public static void ExportToSpreadsheet(DataTable dtData, string name)
        {

            DocExport docEexport = new DocExport();

            docEexport.Dt = dtData; //GridViewHelper.GridView2DataTable(gvValue);

            docEexport.Export(name);

            //System.Web.UI.WebControls.DataGrid dgExport = null;
            //// 当前对话 
            //System.Web.HttpContext curContext = System.Web.HttpContext.Current;
            //// IO用于导出并返回excel文件 
            //System.IO.StringWriter strWriter = null;
            //System.Web.UI.HtmlTextWriter htmlWriter = null;

            //if (dtData != null)
            //{
            //    // 设置编码和附件格式 
            //    curContext.Response.ContentType = "application/vnd.ms-excel";
                
            //    //通过超链接跳转到下载页面,解决弹出该页面的aspx文件要求下载的问题
            //    //指定下载文件名称
            //    curContext.Response.AddHeader("Content-Disposition", "attachment;filename=KPIRealTag.xls");

            //    curContext.Response.ContentEncoding = System.Text.Encoding.UTF8;
            //    curContext.Response.Charset = "GB2312";

            //    // 导出excel文件 
            //    strWriter = new System.IO.StringWriter();
            //    htmlWriter = new System.Web.UI.HtmlTextWriter(strWriter);

            //    // 为了解决dgData中可能进行了分页的情况,需要重新定义一个无分页的DataGrid 
            //    dgExport = new System.Web.UI.WebControls.DataGrid();
            //    dgExport.DataSource = dtData.DefaultView;
            //    dgExport.AllowPaging = false;
            //    dgExport.DataBind();

            //    // 返回客户端 
            //    dgExport.RenderControl(htmlWriter);
            //    curContext.Response.Write(strWriter.ToString());
            //    curContext.Response.End();
            //}

        }
示例#4
0
        protected void btnExport_Click(object sender, EventArgs e)
        {
            if (gvData.Rows.Count > 0)
            {
                DocExport docEexport = new DocExport();

                docEexport.Dt = GridViewHelper.GridView2DataTable(gvData);

                docEexport.Export("SIS实时运行绩效报表");
            }
        }