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

 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表格

上一篇:C# 关键字:new


下一篇:C# 关键字:this