码迷,mamicode.com
首页 > Windows程序 > 详细

WPF场景下查询数据并使用NPOI生成EXCEL表格

时间:2020-06-26 22:39:09      阅读:119      评论:0      收藏:0      [点我收藏+]

标签:set   代码   span   repo   状态   fat   end   idc   string   

 WPF场景下后台生成DataGrid列的代码:

  1. /// <summary>
            /// 通用的出勤表头设置
            /// </summary>
            /// <param name="dgView">DataGrid实例</param>
            /// <param name="dataTable">源数据表</param>
            private void SetDataGridHearedOfAttendance(DataGrid dgView, DataTable dataTable)
                {
                dgView.ItemsSource = dataTable.DefaultView;
                dgView.Columns.Clear();
    
                TBCountMessage.Text = "" + SDate + "" + Edate + "   " +
                    "期间的出勤统计信息为: 正常出勤天数为:  "+rePortDp.NomalAttendancedays +"  天,半天数为:  "+rePortDp.HalfdayAttendancedays +"  个,加班时长为:  "+rePortDp.Workovertime+"  小时";
    
                DataGridTextColumn dategridcolumn = new DataGridTextColumn();
                dategridcolumn.Header = "出勤日期";
                dategridcolumn.Width = 180;
                dategridcolumn.Binding = new Binding("AttendanceDate");
                dategridcolumn.Binding.StringFormat = "yyyy年MM月dd日";
                dgView.Columns.Add(dategridcolumn);
    
                DataGridTextColumn DGTCattendancestatus = new DataGridTextColumn();
                DGTCattendancestatus.Header = "出勤状态";
                DGTCattendancestatus.Width = 120;
                DGTCattendancestatus.Binding = new Binding("AttendanceStatus");
                dgView.Columns.Add(DGTCattendancestatus);
    
    
                DataGridTextColumn DGTCattendanceHelper = new DataGridTextColumn();
                DGTCattendanceHelper.Header = "帮忙对象";
                DGTCattendanceHelper.Width = 120;
                DGTCattendanceHelper.Binding = new Binding("Helper");
                dgView.Columns.Add(DGTCattendanceHelper);
    
    
                DataGridTextColumn DGTCworkovertime = new DataGridTextColumn();
                DGTCworkovertime.Header = "加班时长";
                DGTCworkovertime.Width = 105;
                DGTCworkovertime.Binding = new Binding("WorkOfTime");
                DGTCworkovertime.Binding.StringFormat="0.0";
                dgView.Columns.Add(DGTCworkovertime);
    
                DataGridTextColumn DGTCattendanceremark = new DataGridTextColumn();
                DGTCattendanceremark.Header = "出勤备注";
                DGTCattendanceremark.Width = 300;
                DGTCattendanceremark.Binding = new Binding("AttendanceRemark");
                dgView.Columns.Add(DGTCattendanceremark);
                SetBtnSaveIsEnable(dgView);
    
    
               
    }

WPF场景下查询数据并使用NPOI生成EXCEL表格

标签:set   代码   span   repo   状态   fat   end   idc   string   

原文地址:https://www.cnblogs.com/Use-NPOI/p/12322071.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!