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 #2
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);
        }
        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);
        }