Example #1
0
        private void Export()
        {
            GC.Collect();
            Application excelApp = new ApplicationClass();

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

            if (Session["AdvanceSearchContractResult"] != null)
            {
                Worksheet excelSheet3 =
                    (Worksheet)excelBook.Sheets.Add(Type.Missing, Type.Missing, Type.Missing, Type.Missing);
                excelSheetList.Add(excelSheet3);
                excelSheet3.Name = "员工合同高级查询";
                ExportToExcel(excelSheet3);
            }
            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 btnAverageExport()
        {
            var workbook = new HSSFWorkbook();

            if (Session[SessionKeys.gvTimeSpanStatisticsGroupByDeptSource] as DataTable != null)
            {
                DataTable dtgvTimeSpanStatisticsGroupByDeptSource =
                    Session[SessionKeys.gvTimeSpanStatisticsGroupByDeptSource] as DataTable;
                ExcelUtility.RenderDataTableToExcel(workbook, dtgvTimeSpanStatisticsGroupByDeptSource, "按月统计部门工资");
                ExcelUtility.EmbedImage(workbook, workbook.GetSheet("按月统计部门工资") as HSSFSheet,
                                        ExcelExportUtility.GetImagePath(Session[SessionKeys.TimeSpanStatisticsGroupByDeptLineChartFileNameAndExp].ToString()),
                                        true, new int[] { 0, 10, 0, 10 });
            }
            if (Session[SessionKeys.gvAverageStatisticsTableSource] as DataTable != null)
            {
                DataTable dtgvAverageStatisticsTableSource =
                    Session[SessionKeys.gvAverageStatisticsTableSource] as DataTable;
                ExcelUtility.RenderDataTableToExcel(workbook, dtgvAverageStatisticsTableSource, "人均统计");
                ExcelUtility.EmbedImage(workbook, workbook.GetSheet("人均统计") as HSSFSheet,
                                        ExcelExportUtility.GetImagePath(Session[SessionKeys.AverageStatisticsBarChartFileNameAndExp].ToString()),
                                        true, new int[] { 0, 10, 0, 10 });
            }
            MemoryStream ms = new MemoryStream();

            workbook.Write(ms);
            ms.Flush();
            ms.Position = 0;
            workbook    = null;
            ExcelExportUtility.OutputExcel(Server, Response, "员工工资人均统计", ms);
        }
Example #3
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);
        }
        public void btnExportAnnualAssessClick()
        {
            MemoryStream ms =
                presenter.ExportAnnualAssessAll(Server.MapPath(ConstParameters.Template_AnnualAssessXls));

            if (ms != null)
            {
                ExcelExportUtility.OutputExcel(Server, Response, "绩效评估结果", ms);
            }
        }
Example #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var workbook = new HSSFWorkbook();

            if (Session[SessionKeys.EmployeeStaticsComeAndLeaveTable] as DataTable != null)
            {
                DataTable employeeStaticsComeAndLeaveTable =
                    Session[SessionKeys.EmployeeStaticsComeAndLeaveTable] as DataTable;
                ExcelUtility.RenderDataTableToExcel(workbook, employeeStaticsComeAndLeaveTable, "员工统计");
            }
            ExcelUtility.EmbedImage(workbook, workbook.GetSheetAt(0) as HSSFSheet,
                                    ExcelExportUtility.GetImagePath(Session[SessionKeys.EmployeeStaticsComeAndLeaveBarChart].ToString()),
                                    true, new int[] { 0, 10, 0, 10 });
            ExcelUtility.EmbedImage(workbook, workbook.GetSheetAt(0) as HSSFSheet,
                                    ExcelExportUtility.GetImagePath(Session[SessionKeys.EmployeeStaticsLeaveRateLineChart].ToString()),
                                    true, new int[] { 0, 30, 0, 30 });
            ExcelUtility.EmbedImage(workbook, workbook.GetSheetAt(0) as HSSFSheet,
                                    ExcelExportUtility.GetImagePath(Session[SessionKeys.EmployeeStaticsGenderPieChart].ToString()),
                                    true, new int[] { 0, 50, 0, 50 });
            ExcelUtility.EmbedImage(workbook, workbook.GetSheetAt(0) as HSSFSheet,
                                    ExcelExportUtility.GetImagePath(Session[SessionKeys.EmployeeStaticsEduBgPieChart].ToString()),
                                    true, new int[] { 0, 70, 0, 70 });
            ExcelUtility.EmbedImage(workbook, workbook.GetSheetAt(0) as HSSFSheet,
                                    ExcelExportUtility.GetImagePath(Session[SessionKeys.EmployeeStaticsWorkAgePieChart].ToString()),
                                    true, new int[] { 0, 90, 0, 90 });
            ExcelUtility.EmbedImage(workbook, workbook.GetSheetAt(0) as HSSFSheet,
                                    ExcelExportUtility.GetImagePath(Session[SessionKeys.EmployeeStaticsAgePieChart].ToString()),
                                    true, new int[] { 0, 110, 0, 110 });
            ExcelUtility.EmbedImage(workbook, workbook.GetSheetAt(0) as HSSFSheet,
                                    ExcelExportUtility.GetImagePath(Session[SessionKeys.EmployeeStaticsWorkTypePieChart].ToString()),
                                    true, new int[] { 0, 130, 0, 130 });
            ExcelUtility.EmbedImage(workbook, workbook.GetSheetAt(0) as HSSFSheet,
                                    ExcelExportUtility.GetImagePath(Session[SessionKeys.EmployeeStaticsPositionGradeTowerTable].ToString()),
                                    true, new int[] { 0, 150, 0, 150 });

            if (Session[SessionKeys.EmployeeStaticsOtherStatisticsData] as DataTable != null)
            {
                DataTable EmployeeStaticsOtherStatisticsData =
                    Session[SessionKeys.EmployeeStaticsOtherStatisticsData] as DataTable;
                ExcelUtility.RenderDataTableToExcel(workbook, EmployeeStaticsOtherStatisticsData, "其它统计");
            }
            MemoryStream ms = new MemoryStream();

            workbook.Write(ms);
            ms.Flush();
            ms.Position = 0;
            workbook    = null;
            ExcelExportUtility.OutputExcel(Server, Response, "员工统计", ms);
        }
Example #6
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);
        }
Example #7
0
        public void btnExportAnnualAssessClick()
        {
            //string filename =
            //    presenter.ExportAnnualAssessAll(Server.MapPath(ConstParameters.Template_AnnualAssessXls));
            //if (filename != presenter.JUDGEERROR)
            //{
            //    Export(filename);
            //}
            MemoryStream ms =
                presenter.ExportAnnualAssessAll(Server.MapPath(ConstParameters.Template_AnnualAssessXls));

            if (ms != null)
            {
                ExcelExportUtility.OutputExcel(Server, Response, "绩效评估结果", ms);
            }
        }
Example #8
0
        protected void btnExport_Click(object sender, EventArgs e)
        {
            ExcelExportUtility.ExportContent ExportContentImplement = TemplateBuildStringWriter;
            FileInfo file = ExcelExportUtility.NormalExport("员工调休.xls", ExportContentImplement);

            if (file.Exists)
            {
                Response.Clear();
                Response.Charset         = "GB2312";
                Response.ContentEncoding = Encoding.UTF8;
                Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(file.Name));
                Response.AddHeader("Content-Length", file.Length.ToString());
                Response.ContentType = "application/ms-excel";
                Response.WriteFile(file.FullName);
                Response.End();
            }
        }
        private void EmployeeExport()
        {
            var workbook = new HSSFWorkbook();

            if (Session[SessionKeys.gvEmployeeStatisticsTableSource] as DataTable != null)
            {
                DataTable dtgvDepartmentStatisticsTableSource =
                    Session[SessionKeys.gvEmployeeStatisticsTableSource] as DataTable;
                ExcelUtility.RenderDataTableToExcel(workbook, dtgvDepartmentStatisticsTableSource, "按员工统计报销");
                ExcelUtility.EmbedImage(workbook, workbook.GetSheet("按员工统计报销") as HSSFSheet,
                                        ExcelExportUtility.GetImagePath(Session[SessionKeys.EmployeeReimburseStatisticsBarChart].ToString()),
                                        true, new int[] { 0, 10, 0, 10 });
            }
            MemoryStream ms = new MemoryStream();

            workbook.Write(ms);
            ms.Flush();
            ms.Position = 0;
            workbook    = null;
            ExcelExportUtility.OutputExcel(Server, Response, "员工报销综合统计", ms);
        }
Example #10
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);
        }
Example #11
0
        private void Export()
        {
            GC.Collect();
            Application excelApp = new ApplicationClass();

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

            Worksheet excelSheet3 =
                (Worksheet)excelBook.Sheets.Add(Type.Missing, Type.Missing, Type.Missing, Type.Missing);

            excelSheetList.Add(excelSheet3);
            excelSheet3.Name = "工作计划";
            ExportToExcel(excelSheet3);

            ExcelExportUtility.RemoveBlankWorkSheet(excelBook);
            object nothing    = Type.Missing;
            object fileFormat = XlFileFormat.xlExcel8;
            string path       = ConfigurationManager.AppSettings["EmployeeExportLocation"];

            if (!Directory.Exists(path))         //判断是否存在
            {
                Directory.CreateDirectory(path); //创建新路径
            }
            object file = path + "\\工作计划表" + DateTime.Now.ToBinary() + ".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(file.ToString(), _Context.Server, _Context.Response);
        }
        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);
        }
Example #14
0
        protected void btnExport_Click(object sender, EventArgs e)
        {
            var          workbook  = new HSSFWorkbook();
            MemoryStream ms        = new MemoryStream();
            HSSFSheet    sheet     = workbook.CreateSheet() as HSSFSheet;
            HSSFRow      headerRow = sheet.CreateRow(0) as HSSFRow;

            headerRow.CreateCell(0).SetCellValue(EmployeeWelfare.ConstParemeter.Name);
            headerRow.CreateCell(1).SetCellValue(EmployeeWelfare.ConstParemeter.SocialType);
            headerRow.CreateCell(2).SetCellValue(EmployeeWelfare.ConstParemeter.SocialBase);
            headerRow.CreateCell(3).SetCellValue(EmployeeWelfare.ConstParemeter.SocialYM);
            headerRow.CreateCell(4).SetCellValue(EmployeeWelfare.ConstParemeter.FundAccount);
            headerRow.CreateCell(5).SetCellValue(EmployeeWelfare.ConstParemeter.FundBase);
            headerRow.CreateCell(6).SetCellValue(EmployeeWelfare.ConstParemeter.FundYM);
            headerRow.CreateCell(7).SetCellValue(EmployeeWelfare.ConstParemeter.SupplyAccount);
            headerRow.CreateCell(8).SetCellValue(EmployeeWelfare.ConstParemeter.SupplyBase);
            headerRow.CreateCell(9).SetCellValue(EmployeeWelfare.ConstParemeter.YangLaoBase);
            headerRow.CreateCell(10).SetCellValue(EmployeeWelfare.ConstParemeter.ShiYeBase);
            headerRow.CreateCell(11).SetCellValue(EmployeeWelfare.ConstParemeter.YiLiaoBase);
            // handling value.
            int rowIndex = 1;

            for (int i = 0; i < EmployeeWelfareListViewState.Count; i++)
            {
                HSSFRow dataRow = sheet.CreateRow(rowIndex) as HSSFRow;
                dataRow.CreateCell(0).SetCellValue(EmployeeWelfareListViewState[i].Owner.Name);
                dataRow.CreateCell(1).SetCellValue(EmployeeWelfareListViewState[i].SocialSecurity.Type.Name);
                dataRow.CreateCell(2).SetCellValue(EmployeeWelfareListViewState[i].SocialSecurity.Base.ToString());
                if (EmployeeWelfareListViewState[i].SocialSecurity.EffectiveYearMonth != null)
                {
                    List <string> SocialSecurityYearMonth =
                        EmployeeWelfare.YearAndMonth(EmployeeWelfareListViewState[i].SocialSecurity.EffectiveYearMonth);
                    dataRow.CreateCell(3).SetCellValue(string.Format("{0}年{1}月", SocialSecurityYearMonth[0], SocialSecurityYearMonth[1]));
                }
                dataRow.CreateCell(4).SetCellValue(EmployeeWelfareListViewState[i].AccumulationFund.Account);
                dataRow.CreateCell(5).SetCellValue(EmployeeWelfareListViewState[i].AccumulationFund.Base.ToString());

                if (EmployeeWelfareListViewState[i].AccumulationFund.EffectiveYearMonth != null)
                {
                    List <string> AccumulationFundYearMonth =
                        EmployeeWelfare.YearAndMonth(EmployeeWelfareListViewState[i].AccumulationFund.EffectiveYearMonth);
                    dataRow.CreateCell(6).SetCellValue(string.Format("{0}年{1}月", AccumulationFundYearMonth[0], AccumulationFundYearMonth[1]));
                }
                dataRow.CreateCell(7).SetCellValue(EmployeeWelfareListViewState[i].AccumulationFund.SupplyAccount);
                dataRow.CreateCell(8).SetCellValue(EmployeeWelfareListViewState[i].AccumulationFund.SupplyBase.ToString());
                dataRow.CreateCell(9).SetCellValue(EmployeeWelfareListViewState[i].SocialSecurity.YangLaoBase.ToString());
                dataRow.CreateCell(10).SetCellValue(EmployeeWelfareListViewState[i].SocialSecurity.ShiYeBase.ToString());
                dataRow.CreateCell(11).SetCellValue(EmployeeWelfareListViewState[i].SocialSecurity.YiLiaoBase.ToString());

                rowIndex++;
            }

            workbook.Write(ms);
            ms.Flush();
            ms.Position = 0;

            sheet     = null;
            headerRow = null;
            workbook  = null;
            ExcelExportUtility.OutputExcel(Server, Response, "员工福利表", ms);
            // Export("员工福利表.xls");
        }