示例#1
0
        private void Export()
        {
            string FileName = "绩效考核表" + DateTime.Now.Year + DateTime.Now.Month + DateTime.Now.Day +
                              DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second + DateTime.Now.Millisecond;
            DataTable    dt = CreateTable();
            MemoryStream ms = ExcelExportUtility.DataTableTurnToExcel(dt, "绩效考核表");

            ExcelExportUtility.OutputExcel(Server, Response, FileName, ms);
        }
示例#2
0
        protected void btnExport_Click(object sender, EventArgs e)
        {
            DataTable ret_dt = new DataTable();

            ret_dt.Columns.Add("员工姓名");
            ret_dt.Columns.Add("所属部门");
            ret_dt.Columns.Add("职位");
            ret_dt.Columns.Add("年假起始日");
            ret_dt.Columns.Add("年假到期日");
            ret_dt.Columns.Add("年假总天数");
            ret_dt.Columns.Add("已用天数");
            ret_dt.Columns.Add("剩余天数");
            ret_dt.Columns.Add("备注");
            for (int i = 0; i < VacationSourceViewState.Count; i++)
            {
                DataRow dr = ret_dt.NewRow();
                dr["员工姓名"] = VacationSourceViewState[i] != null &&
                             VacationSourceViewState[i].Employee != null &&
                             VacationSourceViewState[i].Employee.Account != null &&
                             VacationSourceViewState[i].Employee.Account.Name != null
                                             ? VacationSourceViewState[i].Employee.Account.Name
                                             : "";
                dr["所属部门"] = VacationSourceViewState[i] != null &&
                             VacationSourceViewState[i].Employee != null &&
                             VacationSourceViewState[i].Employee.Account != null &&
                             VacationSourceViewState[i].Employee.Account.Dept != null &&
                             VacationSourceViewState[i].Employee.Account.Dept.Name != null
                                            ? VacationSourceViewState[i].Employee.Account.Dept.Name
                                            : "";
                dr["职位"] = VacationSourceViewState[i] != null &&
                           VacationSourceViewState[i].Employee != null &&
                           VacationSourceViewState[i].Employee.Account != null &&
                           VacationSourceViewState[i].Employee.Account.Position != null &&
                           VacationSourceViewState[i].Employee.Account.Position.Name != null
                                            ? VacationSourceViewState[i].Employee.Account.Position.Name
                                            : "";
                dr["年假起始日"] = VacationSourceViewState[i].VacationStartDate;
                dr["年假到期日"] = VacationSourceViewState[i].VacationEndDate;
                dr["年假总天数"] = VacationSourceViewState[i].VacationDayNum;
                dr["已用天数"]  = VacationSourceViewState[i].UsedDayNum;
                dr["剩余天数"]  = VacationSourceViewState[i].SurplusDayNum;
                dr["备注"]    = VacationSourceViewState[i].Remark;
                ret_dt.Rows.Add(dr);
            }
            MemoryStream ms = ExcelExportUtility.DataTableTurnToExcel(ret_dt, "员工年假");

            ExcelExportUtility.OutputExcel(Server, Response, "员工年假", ms);
        }
示例#3
0
        private void btnExport()
        {
            if (Request.QueryString["txtName"] == null ||
                Request.QueryString["listPosition"] == null ||
                Request.QueryString["listEmployeeType"] == null ||
                Request.QueryString["cbRecursionDepartment"] == null ||
                Request.QueryString["listDepartment"] == null ||
                Request.QueryString["ddlEmployeeStatus"] == null)
            {
                return;
            }
            DataTable dt =
                InstanceFactory.CreateEmployeeAccountSetFacade().ExportEmployeeAccountSetFacade(
                    Request.QueryString["txtName"].Trim(), Convert.ToInt32(Request.QueryString["listDepartment"]),
                    Convert.ToInt32(Request.QueryString["listPosition"]),
                    EmployeeTypeUtility.GetEmployeeTypeByID(Convert.ToInt32(Request.QueryString["listEmployeeType"])),
                    Convert.ToBoolean(Request.QueryString["cbRecursionDepartment"]), LoginUser, Convert.ToInt32(Request.QueryString["ddlEmployeeStatus"]));
            MemoryStream ms = ExcelExportUtility.DataTableTurnToExcel(dt);

            ExcelExportUtility.OutputExcel(Server, Response, "员工帐套", ms);
        }
        private void btnExportPersonList()
        {
            //GC.Collect();
            //Application excelApp = new ApplicationClass();
            //excelApp.Visible = false;
            //List<Worksheet> excelSheetList = new List<Worksheet>();
            //Workbook excelBook = excelApp.Workbooks.Add(Type.Missing);
            if (Session[SessionKeys.PersionInAndOutDataTable] != null)
            {
                //Worksheet excelSheet3 =
                //    (Worksheet)excelBook.Sheets.Add(Type.Missing, Type.Missing, Type.Missing, Type.Missing);
                //excelSheetList.Add(excelSheet3);
                //excelSheet3.Name = "员工打卡信息";
                List <AttendanceInAndOutRecord> records = new List <AttendanceInAndOutRecord>();
                foreach (AttendanceInAndOutRecord record in (List <AttendanceInAndOutRecord>)Session[SessionKeys.PersionInAndOutDataTable])
                {
                    records.Add(record);
                }
                DataTable    dataTable = TurnToDataTable(records);
                MemoryStream ms        = ExcelExportUtility.DataTableTurnToExcel(dataTable);
                ExcelExportUtility.OutputExcel(Server, Response, "员工日打卡信息", ms);
            }
            //ExcelExportUtility.RemoveBlankWorkSheet(excelBook);
            //object nothing = Type.Missing;
            //object fileFormat = XlFileFormat.xlExcel8;
            //object file = Server.MapPath(".") + "\\员工打卡信息.xls";
            //if (File.Exists(file.ToString()))
            //{
            //    File.Delete(file.ToString());
            //}
            //excelBook.SaveAs(file, fileFormat, nothing, nothing, nothing, nothing, XlSaveAsAccessMode.xlNoChange,
            //                 nothing, nothing, nothing, nothing, nothing);

            //excelBook.Close(false, null, null);

            //ExcelExportUtility.ReleaseComObject(excelApp, excelBook, excelSheetList);
            //ExcelExportUtility.KillProcess(excelApp, "Excel");
            //ExcelExportUtility.OutputExcel(Server, Response, "员工打卡信息");
        }
        private void btnExport()
        {
            GC.Collect();
            Application excelApp = new ApplicationClass();

            excelApp.Visible = false;
            List <Worksheet> excelSheetList = new List <Worksheet>();
            Workbook         excelBook      = excelApp.Workbooks.Add(Type.Missing);
            MemoryStream     ms             = new MemoryStream();

            if (Session[SessionKeys.InAndOutStatisticsRecordDataTable] as DataTable != null)
            {
                //Worksheet excelSheet3 =
                //    (Worksheet) excelBook.Sheets.Add(Type.Missing, Type.Missing, Type.Missing, Type.Missing);
                //excelSheetList.Add(excelSheet3);
                //excelSheet3.Name = "员工日打卡信息";
                DataTable dtInAndOutStatisticsRecordDataTable =
                    Session[SessionKeys.InAndOutStatisticsRecordDataTable] as DataTable;
                ms = ExcelExportUtility.DataTableTurnToExcel(dtInAndOutStatisticsRecordDataTable);
            }
            //ExcelExportUtility.RemoveBlankWorkSheet(excelBook);
            //object nothing = Type.Missing;
            //object fileFormat = XlFileFormat.xlExcel8;
            //object file = Server.MapPath(".") + "\\员工日打卡信息.xls";
            //if (File.Exists(file.ToString()))
            //{
            //    File.Delete(file.ToString());
            //}
            //excelBook.SaveAs(file, fileFormat, nothing, nothing, nothing, nothing, XlSaveAsAccessMode.xlNoChange,
            //                 nothing, nothing, nothing, nothing, nothing);

            //excelBook.Close(false, null, null);

            //ExcelExportUtility.ReleaseComObject(excelApp, excelBook, excelSheetList);
            //ExcelExportUtility.KillProcess(excelApp, "Excel");
            ExcelExportUtility.OutputExcel(Server, Response, "员工日打卡信息", ms);
        }